0
我有一個從SqlDataSource填充的列表視圖。它根據查詢字符串中的類別值顯示數據庫中的產品列表。我在產品表中的類別是New|Fiction|Auto|Text
。我如何設置默認值來顯示所有類別。從DropdownList中選擇類別。當我在下拉列表中選擇ALL時,我需要顯示所有產品。將多個默認值設置爲SqlDataSource Where條件
DROPDOWNLIST
<asp:DropDownList runat="server" id="ddl" OnSelectedIndexChanged="SelectionChanged" AutoPostBack="true">
<asp:ListItem Text="All" ></asp:ListItem>
<asp:ListItem Text="Fiction" Value="~/Bio.aspx?Category=Fiction" />
<asp:ListItem Text="TextBooks" Value="~/Bio.aspx?Category=Text" />
<asp:ListItem Text="Biography" Value="~/Bio.aspx?Category=Auto" />
<asp:ListItem Text="New Release" Value="~/Bio.aspx?Category=New" />
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:2016_675_z1787626ConnectionString %>" SelectCommand="SELECT * FROM [Bio] WHERE ([Category] = @Category)" >
<SelectParameters>
<asp:QueryStringParameter Name="Category" QueryStringField="Category" Type="String" />
</SelectParameters>
</asp:SqlDataSource>