DropDownList Disabled Items in the list

  • Thread starter Thread starter Ryan Ternier
  • Start date Start date
R

Ryan Ternier

I'm looking for a solution to a problem.

We have a list of 10-100items that will be in a dropdown list. Users need to
select an Item to perform a function.

Each Item has a Heading that it's sorted on, 10 items under 1 heading
(example).

So I would like a list box to show each heading, with all the Items
underneath, but not let the users select headings.

Is there an easy way of doing this? Or should I just use java script to
check the listbox to see if the selected is a heading before submiting?
 
One way of approaching this problem is to derive a new class for the object
and give it a property which denotes if it is a dataitem or a heading, then
when the user clicks on an option, you can ignore it in the code behind.

If however, you want to prevent it causing postback you will have to check
the object in javascript and do a custom validation, unfortunately on the
client side you are limited to the 'option' object which only has value and
text. You could however use the value perhaps as the flag to ignore or not.

Thats off the top of my head, but you may find another way.

In all honesty, I dont think a dropdown list is what you need, I would
consider using some other control.
 
Back
Top