我想按下拉值搜索。我在这种情况下使用 ControlParameters 并希望通过用户选择的下拉列表进行搜索。是否可以使用 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>