protected void DropDownListState_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownListState.SelectedIndex == 0) { DropDownListCity.SelectedIndex = 0; DropDownListCity.Enabled = false; DropDownListBranch.Enabled = false; } else { DropDownListCity.Enabled = true; StatesCities GetCitiesByState = new StatesCities(); DropDownListCity.DataSource = GetCitiesByState.Get_CitiesByStateId(Convert.ToInt32(DropDownListState.SelectedValue)); DropDownListCity.DataTextField = "CityName"; DropDownListCity.DataValueField = "CityID"; DropDownListCity.DataBind(); ListItem listatesCity = new ListItem("Select City", ""); DropDownListCity.Items.Insert(0, listatesCity); } }
protected void States() { StatesCities GetStates = new StatesCities(); DropDownListState.DataSource = GetStates.Get_States(); DropDownListState.DataTextField = "StateName"; DropDownListState.DataValueField = "StateID"; DropDownListState.DataBind(); ListItem listatesState = new ListItem("Select State", ""); DropDownListState.Items.Insert(0, listatesState); ListItem listatesCity = new ListItem("Select City", ""); DropDownListCity.Items.Insert(0, listatesCity); ListItem listatesBranch = new ListItem("Select Branch", ""); DropDownListBranch.Items.Insert(0, listatesBranch); DropDownListCity.Enabled = false; DropDownListBranch.Enabled = false; }