Solved

Default dropdown options

Posted on 2011-03-22
3
321 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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