Here i am having 2 dropdown lists in which an item displayed in List1 should display the appropriate options in list 2 likeways If I select TV in Dropdown List 1 then it should display TV.ON,TV.MUTE & TV.OFF only in Dropdown List 2.
Please Find a solution for this issue
Loading
SenthilkumarPosted Mar 1, 2012, 9:06 AM
Consider you have the dropdowns
1. Dropdown1
2. Dropdown2
Load the first drop down values in the page load.
Dropdown1.DataSource = DataSet1.Tables[0];
Dropdown1.DataTextField = "Name";
Dropdown1.DataValueField = "ID";
Dropdown1.DataBind();
Enable the autopostback property for the first dropdown; and write the index changed event.
protected void Dropdown1_OnInexchanged(object sender, EventArgs e)
{
int _Id = Convert.ToInt32(Dropdown1.SelectedItem.Value.ToString());
//Load the data based on the ID and get some datatable/DataSet/Collection
Dropdown2.DataSource = DataSet2.Tables[0];
Dropdown2.DataTextField = "Name1";
Dropdown2.DataValueField = "ID1";
Dropdown2.DataBind();
}
You can use the AJAX update panel to reload the page again when select in the first drop down.