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

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

------解决方案--------------------
选择全部时候,Value有值没有嘛?
------解决方案--------------------
那要看你是怎么添加这个全部的值了,有木有加,怎么加的?


this.dll.Items.Insert(0,new ListItem("全部","all"));
------解决方案--------------------
 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()));

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

设置你的DropDownList的AutoPostBack属性为True

记得页面加载的时候添加
if (!IsPostBack)
            {
               
            }
------解决方案--------------------
DropDownList的AutoPostBack属性为True  触发时件