Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Default dropdown options

Posted on 2011-03-22
3
Medium Priority
?
328 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 1000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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…
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

971 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