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

DropDownList 默认为空的如何设置

2012-02-13 
DropDownList默认为空的怎么设置?比如asp:DropDownListID dropBeginYear runat server asp:ListI

DropDownList 默认为空的怎么设置?
比如
<asp:DropDownList   ID= "dropBeginYear "   runat= "server ">
<asp:ListItem   Value= "2006 "> 2006 </asp:ListItem>
<asp:ListItem   Value= "2007 "> 2007 </asp:ListItem>
<asp:ListItem   Value= "2008 "> 2008 </asp:ListItem>
<asp:ListItem   Value= "2009 "> 2009 </asp:ListItem>
<asp:ListItem   Value= "2010 "> 2010 </asp:ListItem>
</asp:DropDownList>

页面打开是默认就选中了2006  
问题是我不希望打开时dropdownlist里有值,空着就行
该如何处理
大家帮忙,谢谢!!

[解决办法]
DropDownList1.Items.Add(new ListItem( " ", " "));
[解决办法]
建一个item,text= "请选择 " Value= " "
验证这个不能为空,试试
[解决办法]
孟老大写的是正确的
或者你在 <asp:ListItem Value= "2006 "> 2006 </asp:ListItem> 加一句 <asp:ListItem Value= " "> </asp:ListItem> 不就行了?
[解决办法]
DropDownList1.Items.Add(new ListItem( " ", " "));

绑定完之后这样写就行了.
[解决办法]
DropDownList1.Items.Add(new ListItem( " ", " "));

[解决办法]
DropDownList1.Items.Add(new ListItem( " ", "value "));

value最好加个值

热点排行
Bad Request.