当前位置: 代码迷 >> .NET面试 >> Dropdownlist待
  详细解决方案

Dropdownlist待

热度:2433   发布时间:2013-02-25 00:00:00.0
Dropdownlist在线等待
Dropdownlist控件中的数据从数据库中查询而来,如何设置默认的首项自动被选中?

------解决方案--------------------------------------------------------
默认的首项自动被选中??

DropDownList1.Items.FindByText("某个值").Selected = true;

or

DropDownList1.Items.FindByValue("某个值").Selected = true;
------解决方案--------------------------------------------------------
DropDownList1.Items[指定一个索引].Selected = true;


 如,DropDownList1.Items[1].Selected = true; 最好限制下范围

索引必须小于"DropDownList1.Items.Count" 即索引小于下拉项的个数
  相关解决方案