我用DropDownList显示数据,选择“全部”的时候SelectedValue的值为空,选择其他的都有值,是怎么回事啊?

解决方案 »

  1.   

    选择全部时候,Value有值没有嘛?
      

  2.   

    那要看你是怎么添加这个全部的值了,有木有加,怎么加的?
    this.dll.Items.Insert(0,new ListItem("全部","all"));
      

  3.   

     var res = from a in Member
                          select new { a.MemberID, a.MemberName };
                DropDownList2.DataSource = res;
                DropDownList2.Items.Insert(0, new ListItem("--请选择--", "0"));
                DropDownList2.DataTextField = "MemberName";
                DropDownList2.DataValueField = "MemberID";
                DropDownList2.DataBind();
    or
     DropDownList2.Items.Add(new ListItem("请选择栏目", "0"));
    this.DropDownList2.Items.Add(new ListItem(row["MemberName "].ToString(), row["MemberID"].ToString()));
      

  4.   

    这个问题需要看你是怎么添加ddl下来选项的值的,自己调试下就可以看出来
      

  5.   


    设置你的DropDownList的AutoPostBack属性为True记得页面加载的时候添加
    if (!IsPostBack)
                {
                   
                }
      

  6.   

    DropDownList的AutoPostBack属性为True  触发时件