473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

DropDownList Disabled Items in the list

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
2 3494
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paraki | last post by:
Hi, I have 4 items in a dropdownlist. After selecting the item the dropdownlist gets disabled. this operation is performed in selectedIndexChangeCommited event. Now the problem is, I hignlight...
5
by: DC Gringo | last post by:
I have a dropdownlist that, upon form submission, I'd like to maintain the selected value when I get my result...how do I do that? <asp:dropdownlist Font-Size="8" id="ddlCommunities"...
10
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected =...
0
by: fwirtanen | last post by:
I am building a custom composite control consisting of two drop downs, with parent/child dependancy. The child dropdownlist is updated through client callback when the parent index changes. ...
8
by: tshad | last post by:
Can you databind a dropdownlist to another dropdownlist? I have 2 identical list. I am getting my data from a DataReader, so as soon as I have bound the first DDL, I can't do it again to the next...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
1
by: Eugene Anthony | last post by:
ModifyUserRegistration.aspx --------------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModifyUserRegistration.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC...
3
by: shalini166 | last post by:
hi I need to populate the respective states from the states dropdownlist when a user chooses a country from the country dropdownlist. Similary when the state is selected from the states...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
3
by: =?Utf-8?B?Y21lZWsxXzE5OTk=?= | last post by:
Hello, On a webpage, create an UpdatePanel with two DropDownLists. Set AutoPostBack of DropDownList1 to true. In the SelectedIndexChanged method, refill DropDownList2 and set the focus to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.