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()));