日期:2014-05-18  浏览次数:20483 次

求助 DropDownList SelectedValue 问题
DropDownList4.DataTextField = "classxname";
  DropDownList4.DataValueField = "classxid";
  string cla = dr["classxid"].ToString();
  DropDownList4.SelectedValue = cla;
  DropDownList4.DataBind();


  这里 cal="4";
 可就是DropDownList4.SelectedValue ="";

不知道 怎么会这样

在前面有一个DropDownList1 赋值是成功的,然后DataBind();

------解决方案--------------------
DropDownList4.DataSource= xxx;
DropDownList4.DataTextField = "classxname";
DropDownList4.DataValueField = "classxid";
DropDownList4.DataBind();
string cla = dr["classxid"].ToString();
Response.Write("cla=" + cla); //看有值吗
ListItem x = DropDownList4.Items.FintByValue(cla);
if(x!=null) x.Selected=true;


你的这个cla在列表中吗?是唯一的吗