How to set FilterParameters property of a datasource?

218 views Asked by At

I have two dropdownlists, a checkbox and a gridview that contains images. the asp code looks like this.

<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

1

There are 1 answers

1
Steve Wellens On

Shouldn't the ID's match?

<asp:ControlParameter ControlID="dLCategory" 

<asp:DropDownList ID="dlIconSize"