如何对下拉列表中的项目进行分组 [英] how to group items in drop down list

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

问题描述


我有一个下拉列表,我想将项目分为两组,在第一组中,我想显示组名作为标题,即印度,在此组状态下应显示,但印度不是项目,这意味着我不应该只能选择选定的州,第二组也应与第一组相同.标题应显示该地区下的州.
我可以使用asp.net中的下拉列表控件添加项目,但如何将名称设置为组.
有人可以帮助我吗?.


i have a drop down list and i want to divide items into two groups, at first group i want to display group name as a title i.e.,india, under this group states should display, but india is not a item means i should not be selected only states should selected, second group also same as first here title is states under this districts should display.
i can add item using drop down list control in asp.net but how to set name to group.
can anybody help me plz..

推荐答案

尝试一下:
Try This:
<select id="ListBox1" >
       <optgroup label="India"></optgroup>
           <option>State1</option>
           <option>State2</option>
           <option>State3</option>
       <optgroup label="Country">  </optgroup>
           <option>State1</option>
           <option>State2</option>
           <option>State3</option>
   </select>


使用选项组
这是代码:
Use Option Group
Here is code : ASP.NET DropDownList with OptionGroup support[^][^]


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

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