如何给 dropdownlist 加“------请选择------” dropdownlist.item.add(“----请选择-----”,0) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 UNION SELECT 0 AS EXPR1, '----请选择-----' AS EXPR2 FROM SYS.DUAL dw_SoftClass.Items.Add(new ListItem("----请选择-----", "0")); AppendDataBoundItem设为true.然后有个技巧就是<ListItem Value="">----请选择-----</ListItem>Value="":这样做是当DropDownList绑定的字段值在数据库里是null时,DropDownList会自动选择“---请选择----”这一项。这个试一下就知道了。 <asp:DropDownList DataSourceID="..." AppendDataBoundItems="true"> <ListItem Value="">请选择</ListItem>...这样子就可以up里直接加item了。 dropdownlist.item.add(“----请选择-----”,0) protected void DropDownList2_Init(object sender, EventArgs e) { DropDownList2.Items.Insert(0, "-----请选择-----"); { AppendDataBoundItems="true"手动加就行了,因为后面的数据绑定会追加到后面,而不会覆盖 dw_SoftClass.Items.Add(new ListItem("----请选择-----", "0"));这个不错 DropDownList控件有个 AppendDataBoundItems 属性,把它设置为true,就可以了试下下面的代码吧,这个你绑定数据后,被选择的一项就是"--请选择--"<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true"> <asp:ListItem Text ="--请选择--" Value ="--请选择--"></asp:ListItem> </asp:DropDownList> sql相同数据只显示一条 ckeditor4.0+ckfinder如何配置呀? asp.net 的PagerTemplate 问题 请教 急............ Web新记录提示怎么做 viewstate问题 如何向数据库可存入'这个符号,比如string aa="'hao'"? 这种方式和用sql语句直接插入有什么不同???? 我用一本书的例子时 WEB.config中定义的错误页面什么情况下会跳转? 一个小小问题.请哪位高手进来解决一下... 为什么index.asp可以运行,而之后的链接提示错误不能运行呢? Datalist嵌套的绑定问题
<ListItem Value="">----请选择-----</ListItem>Value="":这样做是当DropDownList绑定的字段值在数据库里是null时,DropDownList会自动选择“---请选择----”这一项。这个试一下就知道了。
<ListItem Value="">请选择</ListItem>
...
这样子就可以up里直接加item了。
dropdownlist.item.add(“----请选择-----”,0)
{
DropDownList2.Items.Insert(0, "-----请选择-----");
{
手动加就行了,因为后面的数据绑定会追加到后面,而不会覆盖
这个不错
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true">
<asp:ListItem Text ="--请选择--" Value ="--请选择--"></asp:ListItem>
</asp:DropDownList>