Default dropdown options

Posted on 2011-03-22
Last Modified: 2012-05-11
I have 2 dropdown boxes that default to ALL.  The 2nd dropdown box is populated based on the selection from the first dropdown.

Can somebody please tell me how I can hide the All option in the 2nd dropdown when an item from the first dropdown is selected.


<div <asp:Label  ID="lbldrop2" runat="server">drop2</asp:Label>
                    <telerik:RadComboBox ID="drop2"    runat="server"></telerik:RadComboBox>

code behind

    public static void drop2(RadComboBox drop2, int drop2Id)

            Drop2.DataSource = Drop2Data(Drop2Id).Data;
            Drop2.DataTextField = "Value";
            Drop2.DataValueField = "Key";

--ONLY want to display if dropdown 1 does not have an item selected            
drop2.Items.Insert(0, new RadComboBoxItem("All", "0"));


Open in new window

Question by:cjJosephj
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 11

Expert Comment

by:Kusala Wijayasena
ID: 35195574
Try this:

if(Drop1.SelectedIndex != 0) //In here, we assume that index "0" of "Drop1 is "All"
    Drop2.Items.Insert(0, new RadComboBoxItem("All", "0"));

Open in new window

LVL 11

Accepted Solution

Kusala Wijayasena earned 250 total points
ID: 35195584
Sorry it should be corrected as follows (typo)

if(Drop1.SelectedIndex == 0) //In here, we assume that index "0" of "Drop1 is "All"
    Drop2.Items.Insert(0, new RadComboBoxItem("All", "0"));

Open in new window


Expert Comment

ID: 35196531
or try this:
if(Drop1.SelectedIndex == 0)
 for (int i=0;i<Drop2.Items.Count;i++)

Open in new window


Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question