views:

31

answers:

1

Situation: There is a page with 2 dropdowns. On clicking the first drop down, you get a list of companies. After selecting a company, the second dropdown, labelled Comapany's Project, should automatically customise its list to the list of projects associated with the selected company. How can the second drop down be achieved?

A: 

At the first dropdown, bind the SelectedIndexChanged event to a method that refreshes the second dropdown.

Something like:

   public void Form1()
    {
               this.dropdown1.SelectedIndexChanged += 
            new System.EventHandler(ComboBox1_SelectedIndexChanged);
    }
    public void DropDown1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
       dropdown2.ClearItems();
      dropdown2.AddRange(GetProductsBasedOnCompany(dropdown1.SelectedItem));
    }
Ngu Soon Hui