首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

DropDownList SelectedValue 有关问题

2012-04-23 
求助 DropDownList SelectedValue 问题DropDownList4.DataTextField classxnameDropDownList4.DataVa

求助 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在列表中吗?是唯一的吗

热点排行