簡體   English   中英

如何設置數據源的FilterParameters屬性?

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

我有兩個下拉列表,一個復選框和一個包含圖像的gridview。 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>

<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" />

<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>

但是,當我嘗試從下拉列表中過濾數據時,它不會過濾數據,它會顯示相同的數據,請指導我

ID不應該匹配嗎?

<asp:ControlParameter ControlID="dLCategory" 

<asp:DropDownList ID="dlIconSize" 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM