如何在下拉列表中添加取消选择的项目 [英] how to add an unselect item in dropdownlist

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

问题描述

我想在asp.net中为印度城市创建一个下拉列表.
我想以单个ddl的状态显示城市,其中状态名称是未选中的项目
具有不同的背景.
我该怎么办.
请给我发代码.

预先感谢.

I want to create a Dropdownlist in asp.net for cities of India.
i want to show cities statewise in single ddl where state name is an unselected item
with different background.
How could i do it.
Please send me the code.

Thanks in advance.

推荐答案

如果您设置了该项目,则不希望将其选择为应该可用的禁用".
If you set the item, that you do not want to be selectable as "disabled" that should work.


我解决了这个问题.
首先,我使用xml中的循环按州根据城市填写了ddl.
然后在项目的值字段中填写州和城市的属性ID.
我再次写了一个javascript函数.
通过检查每个选项的值来实现此功能.如果值是状态类型,则为disable ="disabled";
可以.
Hi,i solved this problem.
first i fill the ddl by cities according to state using loop from xml.
then in the value field of items i fill the attribute id of state and cities.
Again i write a javascript function.
in this function by checking value of each option. if value is type state then the disabled="disabled";
It works.


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

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