我们在修改操作的时候,需要绑定该对象已经有的信息,那么怎么办呢?
方法一:
this.DropDownList1.SelectedIndex = this.DropDownList1.Items.IndexOf(this.DropDownList1.Items.FindByText("字符串"));
或者
this.DropDownList1.SelectedIndex = this.DropDownList1.Items.IndexOf(this.DropDownList1.Items.FindByValue("字符串"));
方法二:
在DropDownList1的DataBound事件中写:
DropDownList1.Items.FindByValue("字符串").Selected=true;
或者
DropDownList1.Items.FindByText(“字符串").Selected = true;
原帖地址:http://hi.baidu.com/suyineng/blog/item/514de33cdcea1308baa167ae.html
本文介绍两种在ASP.NET中使用DropDownList控件时,如何将已存在的选择项设置为默认选中状态的方法。一种是在页面加载时通过索引或文本匹配来设置,另一种是在DataBound事件中直接设置。
1162

被折叠的 条评论
为什么被折叠?



