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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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