AutoPostBack="True" DropDownList选不到值  AutoPostBack="false" 就可以取到选多几次,DropDownList连值都不绑定了,下拉变为空
<asp:ScriptManager ID="ScriptManager1" runat="server">
                            </asp:ScriptManager>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                            
 <asp:DropDownList ID="lstType"   style="width:98%"  AutoPostBack="True" runat="server"   TabIndex="1"   onselectedindexchanged="lstType_SelectedIndexChanged"> </asp:DropDownList><asp:DropDownList ID="lstProductType" style="width:98%"   TabIndex="2"  runat="server"> </asp:DropDownList> 
 </ContentTemplate>
                            </asp:UpdatePanel>if ( !IsPostBack)
        {
            Getlist("select  id,name from M_MenuHead ", lstType, "name", "id");
            
                   
        } private void Getlist(string strSQL, DropDownList DList, string textt, string valuee)
    {
        DataSet dst = new DataSet();
        dst = SqlHelper.ExecuteDataset(SqlHelper.Conn, CommandType.Text, strSQL);
            DList.DataSource = dst;
            DList.DataTextField = textt;
            DList.DataValueField = valuee;
            DList.DataBind();
            DList.Items.Insert(0, new ListItem("== select ==", ""));
    }

解决方案 »

  1.   

    protected void lstType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstType.SelectedValue != "")
            {
                Getlist("select  product_type,name from M_MenuChildren where pid=" + lstType.SelectedValue + "", lstType, "name", "product_type");        }
        }
      

  2.   

    很明显你的sql语句没有取出  textt和valuee的值
    你的sql语句select  id,name from M_MenuHead
    只读取了id和name
      

  3.   

    DropDownList选两次就绑定不到值了
      

  4.   

    不好意思。我没看到你传进来的参数是name和id
      

  5.   

    两次绑定的都是lstType 当然错了
      

  6.   

    看了你的代码,发现你的两次bind的都是同个dropdownlist,第2次的onindexchanged传的就是product_type了,sql查到了空的数据原
      

  7.   

    你为什么要这样绑定呢。你应该返回一个DataTable啊
      

  8.   

    private void Getlist(string strSQL, DropDownList DList, string textt, string valuee)
        {
            DataSet dst = new DataSet();
            dst = SqlHelper.ExecuteDataset(SqlHelper.Conn, CommandType.Text, strSQL);
                DList.DataSource = dst.Tables[0];
                DList.DataTextField = textt;
                DList.DataValueField = valuee;
                DList.DataBind();
                DList.Items.Insert(0, new ListItem("== select ==", ""));
        }