protected void ddlEnvironment_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlEnvironment.SelectedIndex == 0)
{
ddlServers.Items.Add("item1");
}
if (ddlEnvironment.SelectedIndex == 1)
{
ddlServers.Items.Add("item2");
}
if (ddlEnvironment.Text == "Production")
{
}
}
The above is not working. When I make a selection on ddlEnvironment and it is the first item on the list (index 0), the other dropdownlist is not upading with “item1”. Why?
There could be different reasons by default dropdown list do no do postback.
AutoPostBack="true"You bind the ddlEnvironment in !Page.IsPostBack block so that it maintains its state on postback