0
SqlDataSourceから読み込まれたリストビューがあります。クエリ文字列のカテゴリ値に基づいて、データベースの製品リストを表示します。商品表のカテゴリはNew|Fiction|Auto|Text
です。どのように私はすべてのカテゴリを表示するデフォルト値を設定することができます。カテゴリはDropdownListから選択されています。ドロップダウンリストでALLを選択すると、すべての製品を表示する必要があります。複数の既定値をSqlDataSourceに設定する条件
の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>