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

DropDownList下拉表不能选。总调回第一个
本帖最后由 happysun85 于 2013-02-01 17:34:10 编辑
  <div id="class"><h3>选择分类</h3>
            
                 <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="DropDownList1_SelectedIndexChanged">
                 </asp:DropDownList>  
               
                 <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="DropDownList2_SelectedIndexChanged">
                 </asp:DropDownList>

                 <asp:DropDownList ID="DropDownList3" runat="server">
                 </asp:DropDownList>               
            </div>

就是第2个下拉表。不管我选哪一项。他都会跳回第一个“宠物生活”

------解决方案--------------------
原因可能:

1. 在PageLoad中,设置了DropDownList选择的项目,这样每次postback都会设置这一个,解决方法:在PageLoad中判断,IsPostBack;
2. 是否有禁用ViewState的设置?如果设置禁用ViewState,无法保存已经选定的条目的值。

------解决方案--------------------
IsPostBack;90%是你没有if(!IsPostBack){
绑定下拉列表;
}
控制回发
------解决方案--------------------
嗯,首次加载里面获取绑定第一个dropdownlist的数据源。