zandur
asked on
[ASP.NET] Disable particular items in a dropdownlist
I have a dropdownlist that I populate in the code-behind.
In this dropdownlist I want to disable some listitems to prevent the user from selecting them . they are in the list for clarification only.
Is this possible to do from the code behind?
In this dropdownlist I want to disable some listitems to prevent the user from selecting them . they are in the list for clarification only.
Is this possible to do from the code behind?
I would really suggest against using OPTGROUP because that is not what that tag is intended for ... unless grouping of OPTIONs is what you really need to do.
Instead I would recommend adding a disabled attribute to the individual OPTIONS that should be DISABLED:
myDropDownList.Items[0].At tributes.A dd("disabl ed", "disabled");
Instead I would recommend adding a disabled attribute to the individual OPTIONS that should be DISABLED:
myDropDownList.Items[0].At
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
here is an article that shows you how to create a control to do this:
http://www.aspnetmania.com/Code/Code/128.html
The article is in russian... but C# is the same everywhere in the world so the code is all you need :)