根据DropDownList的控件的显示文本选中指定项

使用ASP.NET中的DropDownList控件赋值时,大多数时候的用法为:

DropDownList1.SelectedValue = value;

可是如果要根据显示文本来确定控件的选中项时如何用呢?

DropDownList1.Text = text;

实际使用中,这个方法是不行的。应该这样:

DropDownList1.SelectedValue = DropDownList1.Items.FindByText(text).Value;

或者

DropDownList1.Items.FindByText(text).Selected = true;
 

posted on 2009-10-21 09:23  alon  阅读(717)  评论(0编辑  收藏  举报

导航