在下拉菜单中插入空项目 [英] Insert Empty item in dropdown menu

查看:52
本文介绍了在下拉菜单中插入空项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想在下拉菜单项列表中插入空项.因为加载页面后,我不想显示任何项目,所以我需要从列表中选择它.有什么办法可以将初始值设置为空...?

Hi,


I want to Insert Empty item into dropdown menu items list. because when page has been loaded i dont want to display any item i need to select it from list. is there any way to make initial value as empty...?

推荐答案

尝试将其添加到列表顶部.
ddl.Items.Add(''-Select-'');
然后,在需要时,将selectedIndex设置为它.默认情况下,它将是第一个,因此是-Select-.您可以根据需要在内部处理其代码.
Try adding this at the top of list.
ddl.Items.Add(''-Select-'');
Then whenever needed, set the selectedIndex to it. By default it will be the first one, and thus -Select-. You can handle your code internally for it''s value if needed.


这篇关于在下拉菜单中插入空项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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