By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

DropDownList Disabled Items in the list

P: n/a
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?
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

--
Best Regards

The Inimitable Mr Newbie
"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl...
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?

Nov 19 '05 #2

P: n/a
HTML doesnt support disabling some of the <option>s in a dropdown list...
javascript to check if the user selected a heading and deselcting it
immediatly may be a good option..

I remebered replying to a similar question abt disabling items in a list..
this javascriot code may help ..

http://groups.google.com/group/micro...6e7fa46b06280a

"Ryan Ternier" wrote:
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?

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.