/// <summary> /// Region dropdownlist SelectedIndexChanged event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ddlRegion_SelectedIndexChanged(object sender, EventArgs e) { // Bind city dropdownlist based on region value string strRegion = string.Empty; strRegion = ddlRegion.SelectedValue; List <string> list = null; list = RetrieveDataFromXml.GetCityByRegion(strRegion); ddlCity.Items.Clear(); ddlCity.DataSource = list; ddlCity.DataBind(); ddlCity.Items.Insert(0, new ListItem("Select City", "-1")); // Initialize city dropdownlist selected index hdfDdlCitySelectIndex.Value = "0"; // Enable city dropdownlist when it has items if (list.Count > 0) { ddlCity.Enabled = true; } else { ddlCity.Enabled = false; } }
/// <summary> /// Get city basing on region value /// </summary> /// <param name="strValue">The region value</param> public void RetrieveCityByRegion(string strValue) { List <string> list = RetrieveDataFromXml.GetCityByRegion(strValue); WriteData(list); }