Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net ControlParameter-语法错误:“Where”运算符后缺少操作数_Asp.net_Vb.net_Gridview - Fatal编程技术网

Asp.net ControlParameter-语法错误:“Where”运算符后缺少操作数

Asp.net ControlParameter-语法错误:“Where”运算符后缺少操作数,asp.net,vb.net,gridview,Asp.net,Vb.net,Gridview,我想按下拉值搜索。我在这个实例中使用ControlParameters,希望通过用户选择的下拉菜单进行搜索。是否可以使用控制参数?我已经把错误放在下面了,但是我得到的错误是 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/

我想按下拉值搜索。我在这个实例中使用ControlParameters,希望通过用户选择的下拉菜单进行搜索。是否可以使用控制参数?我已经把错误放在下面了,但是我得到的错误是

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">

            <p>Show all employees with the following title:</p>

            <asp:SqlDataSource id="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:mySQLConnectionString%>"
                SelectCommand="SELECT * FROM tblmovie"
                FilterExpression="MovieID='{0}' or MovieName Like '%'{1}'%' and {2} Like '%'{3}'%'">
                <FilterParameters>
                      <asp:ControlParameter Name="MovieID"  ControlId="DropDownList1" PropertyName="SelectedValue"/>
                      <asp:ControlParameter Name="MovieName" ControlId="DropDownList2" PropertyName="SelectedValue"/>                         
                      <asp:ControlParameter Name="Search" ControlId="DropDownList3" PropertyName="SelectedValue"/>         
                      <asp:ControlParameter Name="Search1" ControlId="txtSearch" PropertyName="text" Type="String"/>  
                </FilterParameters>
            </asp:SqlDataSource>

<table style="width: 650px" border="0" cellpadding="0" cellspacing="1" >
<tr>

<td style="width: 150px;">
Movie ID
 <asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True">
                    <asp:ListItem Value="888">Please Select...</asp:ListItem>            
                <asp:ListItem>1</asp:ListItem>
                <asp:ListItem>2</asp:ListItem>
                <asp:ListItem>3</asp:ListItem>
            </asp:DropDownList>
</td>
<td style="width: 150px;">
Movie Name
 <asp:DropDownList
                id="DropDownList2"
                runat="server"
                AutoPostBack="True">    
                 <asp:ListItem Value="999">Please Select...</asp:ListItem>              
                <asp:ListItem>1</asp:ListItem>
                <asp:ListItem>2</asp:ListItem>
                <asp:ListItem>3</asp:ListItem>
            </asp:DropDownList>
</td>

<td style="width: 150px;">
Search
        <asp:TextBox ID="txtSearch" runat="server" AutoPostBack="True" />
</td>
<td style="width: 150px;">
Where
<asp:DropDownList  id="DropDownList3" runat="server" AutoPostBack="True">
                <asp:ListItem>Please Select...</asp:ListItem>            
                <asp:ListItem>MovieName</asp:ListItem>          
                <asp:ListItem>MovieID</asp:ListItem>            
                <asp:ListItem>Oscars</asp:ListItem>                      
</asp:DropDownList>
</td>
</tr>
<tr><td colspan="4">
<p>
</p>
<p></p>
</td></tr>
<tr>
 <td colspan="4">
            <asp:GridView  id="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False"  Width="600px">
                <columns>                 
                    <asp:BoundField HeaderText="Movie Name" DataField="MovieName"  />
                    <asp:BoundField HeaderText="MovieID" DataField="MovieID" />
                    <asp:BoundField HeaderText="Release Date" DataField="ReleaseDate" />
                     <asp:BoundField HeaderText="Oscars" DataField="Oscars" />
                </columns>
            </asp:GridView>
   </td>
   </tr>     
   </table>  
 </form>
    </body>
</html>
我觉得很奇怪

FilterExpression=MovieID={0}或类似于“{1}%”的MovieName或类似于Oscars={2},其中{3}类似于“%txtSearch.text%”>

我不认为这个词应该在哪里?它应该是AND还是or


在我看来,似乎有一个隐式表达式,您不必在筛选器表达式的开头键入WHERE。

好的,因此我得到了一个错误语法错误:“999”运算符后缺少操作数。我已将{0}的值更改为888,因此我知道它现在位于{0}和{1}连接点……您当前的代码是什么?重新邮寄。您想做什么?我想有效地使用where语句,即使用,在本例中,用户选择要搜索的列,即Firstname/LastName。我已经报告了我的代码。我研究的另一个解决方案是SessionParameters。在我尝试将columnname设置为变量之前,这两种类型的代码都有效。999似乎来自:请选择。。。这看起来像是你应该有列名的地方?如果您有SQL语句,并且像“%…%”这样的999语句,这将是一个问题。
 FilterExpression="MovieID={0} or MovieName Like '%{1}%' or Oscars={2}  Where {3} Like '% txtSearch.text %'">