当前位置: 代码迷 >> ASP.NET >> 怎么让DropDownList装入后不显示任何项值
  详细解决方案

怎么让DropDownList装入后不显示任何项值

热度:6378   发布时间:2013-02-25 00:00:00.0
如何让DropDownList装入后不显示任何项值
我要实现联动,打算在DropDownList1的SelectedIndexChanged事件中为DropDownList2装载相关项,这一过程没什么问题。

麻烦在于当我在Page_Load事件中给DropDownList1填充项后,DropDownList1总会自动显示第1项的内容,而我打算在用户选择之前DropDownList1为空白,可是即使加一句DropDownList1.SelectedIndex   =   -1也无法实现。



------解决方案--------------------------------------------------------
在DropDownList1.DataBind();之后加
DropDownList1.Items.Insert(0, new ListItem( " ", "0 "));


------解决方案--------------------------------------------------------
DropDownList1.Items.Insert(0, new ListItem( "==请选择== ", "0 "));
  相关解决方案