protected void BillingCountryDropDownList_SelectedIndexChanged(object sender, EventArgs e) { DropDownList countryDropDownList = (DropDownList)sender; try { ServiceAccess serviceLoader = ServiceAccess.GetInstance(); BillingStateDropDownList.Items.Clear(); int countryId = Convert.ToInt32(countryDropDownList.SelectedValue); if (countryId == 0) { BillingStateDropDownList.Items.Add(new ListItem("Choose a State", "")); } else { CommonService.CommonService commonService = serviceLoader.GetCommon(); IList <CommonService.StateInfo> states = commonService.GetStates(countryId); BillingStateDropDownList.DataSource = states; BillingStateDropDownList.DataValueField = "StateId"; BillingStateDropDownList.DataTextField = "Name"; BillingStateDropDownList.DataBind(); } } catch (Exception ex) { } }
protected void CountryDropDownList_SelectedIndexChanged(object sender, EventArgs e) { DropDownList countryDropDownList = (DropDownList)sender; try { ServiceAccess serviceLoader = ServiceAccess.GetInstance(); StateDropDownList.Items.Clear(); int countryId = Convert.ToInt32(countryDropDownList.SelectedValue); if (countryId == 0) { StateDropDownList.Items.Add(new ListItem("<Select a State>", "0")); } else { CommonService.CommonService commonService = serviceLoader.GetCommon(); IList <CommonService.StateInfo> states = commonService.GetStates(countryId); StateDropDownList.DataSource = states; StateDropDownList.DataValueField = "StateId"; StateDropDownList.DataTextField = "Name"; StateDropDownList.DataBind(); } } catch (Exception ex) { log.Error("UNKNOWN ERROR:", ex); } }