Adding Line To Asp.net To Listbox
I need a line added to a listbox in ASP.NET to provide some separation from the many options the user can choose from. Currently, we have over 20 different options for the user to
Solution 1:
You can use the optgroup tag to give separation.
<select><optionvalue="XX"/><optgrouplabel="separation"/><optionvalue="BB"/></select>
To give only a line you will need to do some trickery. See below
<styletype="text/css">
optgroup {border-bottom:solid thin black; width:100%;}
</style><select><optionvalue="XX"/><optgrouplabel=" "/><optionvalue="BB"/></select>
If your data is already loaded you could run some jquery after.
$('select option[value="XX"]').after('<optgroup label=""/>');
Solution 2:
There is no out-of-the box possibility to create option-groups from DropDownLists nor Listboxes in asp.net.
Found those articles providing a server-side and client-side solution to achieve what you are looking for:
Dropdownlist control with <optgroup>s for asp.net (webforms)?
Post a Comment for "Adding Line To Asp.net To Listbox"