Solved

Default dropdown options

Posted on 2011-03-22
3
320 Views
Last Modified: 2012-05-11
Hi,
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.

Thanks

aspx.   
<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";

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

        </div>

Open in new window

0
Comment
Question by:cjJosephj
  • 2
3 Comments
 
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


-Kusala
0
 
LVL 11

Accepted Solution

by:
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


-Kusala
0
 
LVL 2

Expert Comment

by:enkor
ID: 35196531
or try this:
if(Drop1.SelectedIndex == 0)
{
 for (int i=0;i<Drop2.Items.Count;i++)
 {
   Drop2.Items[i].Enabled=false;
 }
}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now