如何添加“选择选项”在asp的下拉菜单中 [英] How to add "Select Option" in dropdown menu in asp

查看:342
本文介绍了如何添加“选择选项”在asp的下拉菜单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试在下拉菜单中添加选择选项项目。



我的数据来自sql到数据源

但它直接显示项目列表。



例如:



Item1

Item2

Item3

Item4







我如何首先添加选择项目选项

解决方案

这取决于你如何创建你的下拉列表你没有给我们看,所以很难给出一个具体的答案,但它会是这样的



 <   asp:DropDownList     ID   =  DropDownList1    runat   =  server    AppendDataBoundItems   =  true >  
< span class =code-keyword>< asp:ListItem = 文字 = 选择选项 / >
< / asp:DropDownList >





要添加的重要属性是AppendDataBoundItems


HI Ajay,



请试试这个,



comboboxname。 Items.Insert(0,New ListItem( - Select - ,))



谢谢,

Aniket

Hi,
I am trying To add "Select Option" item in dropdown menu.

My data is coming from sql through a data source
But it directly displays item list.

for eg:

Item1
Item2
Item3
Item4



how do i add "Select Item" option at first

解决方案

It depends how you are creating your dropdown which you haven't shown us so it's hard to give a specific answer, but it'll be something like this

<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true">
    <asp:ListItem Value="" Text="Select Option" />
</asp:DropDownList>



The important attribute to add is "AppendDataBoundItems"


HI Ajay,

Please try this,

comboboxname.Items.Insert(0, New ListItem("-- Select --", ""))

Thanks,
Aniket


这篇关于如何添加“选择选项”在asp的下拉菜单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆