简体   繁体   English

如何设置数据源的FilterParameters属性?

[英]How to set FilterParameters property of a datasource?

I have two dropdownlists, a checkbox and a gridview that contains images. 我有两个下拉列表,一个复选框和一个包含图像的gridview。 the asp code looks like this. asp代码如下所示。

<asp:DropDownList ID="dLSubCat" runat="server" 
            DataSourceID="SubCat" DataTextField="NAME" 
            DataValueField="SUBCAT_ID" 
            AutoPostBack="True">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SubCat" runat="server" 
            ConnectionString="<%$ ConnectionStrings:GalleryConnectionString %>" 
            SelectCommand="SELECT * FROM [SubCategory] WHERE ([CAT_ID] = @CAT_ID)">
            <SelectParameters>
                <asp:ControlParameter ControlID="dLCategory" Name="CAT_ID" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

and

<asp:DropDownList ID="dlIconSize" runat="server" AutoPostBack="True">
           <asp:ListItem>16x16</asp:ListItem>
           <asp:ListItem>24x24</asp:ListItem>
           <asp:ListItem>32x32</asp:ListItem>
           <asp:ListItem>48x48</asp:ListItem>
           <asp:ListItem>64x64</asp:ListItem>
            <asp:ListItem>72x72</asp:ListItem>
           <asp:ListItem>96x96</asp:ListItem>
           <asp:ListItem>128x128</asp:ListItem>
           </asp:DropDownList>
<asp:CheckBox ID="chKBtn" runat="server" Text="Black n White" />

and

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="ID" DataSourceID="SqlDataSource2">
            <Columns>
               <asp:TemplateField HeaderText="Image">
        <ItemTemplate>
        <asp:Image ID="Image1" runat="server" 
            ImageUrl='<%# "imagehandler.ashx?ID=" + Eval("ID")%>'/>
        </ItemTemplate>
        </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:GalleryConnectionString %>" 
            EnableCaching="True"
            SelectCommand="SELECT * FROM [Icon]" 
            FilterExpression="SUBCAT_ID lIKE '{0}' OR ICON_SIZE Like '{1}' OR BLACKWHITE Like '{2}' ">
            <FilterParameters>
            <asp:ControlParameter ControlID = "dLSubCat" 
            PropertyName = "SelectedValue" />
            <asp:ControlParameter ControlID = "dlIconSize" 
            PropertyName = "SelectedValue" />
            <asp:ControlParameter ControlID = "chKBtn" PropertyName = "Checked" />
            </FilterParameters></asp:SqlDataSource>

but when i try to filter data from dropdownlists it does not filter the data it shows same data Kindly guide me 但是,当我尝试从下拉列表中过滤数据时,它不会过滤数据,它会显示相同的数据,请指导我

Shouldn't the ID's match? ID不应该匹配吗?

<asp:ControlParameter ControlID="dLCategory" 

<asp:DropDownList ID="dlIconSize" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM