日期:2014-05-17  浏览次数:20528 次

GridView中两个DropDownList如何过滤
GridView中有两个DropDownList列A,B,现在想实现当点击A列下拉框,选中某值A1后,B列能自动通过A1值过滤出B1、B2、B3、......等子项,如何实现?
------解决方案--------------------
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
            onrowdatabound="GridView2_RowDataBound">
        <Columns>
         <asp:TemplateField HeaderText="住址">
                <ItemTemplate>
                    <asp:DropDownList ID="DDLAddress" runat="server" Width="90px" />
                </ItemTemplate>
                <EditItemTemplate>
                   
                  
                </EditItemTemplate>
                <ItemStyle Width="100px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="性别">
                <ItemTemplate>
                  <asp:DropDownList ID="DDLSex" runat="server" Width="90px" AutoPostBack="True" onselectedindexchanged="DropDown_sex_SelectedIndexChanged" />
                </ItemTemplate>
                <EditItemTemplate>
                  
                    
                </EditItemTemplate>
                <ItemStyle Width="100px" />
            </asp:TemplateField>
            </Columns>
        </asp:GridView>
后台DropDown_sex_SelectedIndexChanged 写绑定
------解决方案--------------------
LZ这个功能叫下拉框的联动,
大致的代码和LS差不多,需要具体实例去51aspx上搜,很多的
------解决方案--------------------
A的值选定后,你能取到A的值吧,然后取B的数据源时在where条件那加上呗!
------解决方案--------------------
http://www.eesai.com/info/AICL94MLSQW/0.html