protected void Country_SelectedIndexChanged(object sender, EventArgs e) { if (dvAddress.CurrentMode == DetailsViewMode.Edit) { strCurrentMode = "Edit"; } else if (dvAddress.CurrentMode == DetailsViewMode.Insert) { strCurrentMode = "Insert"; } DropDownList ddCountry = (DropDownList)dvAddress.FindControl("ddCountry" + strCurrentMode); DropDownList ddProvince = (DropDownList)dvAddress.FindControl("ddProvince" + strCurrentMode); DropDownList ddCity = (DropDownList)dvAddress.FindControl("ddCity" + strCurrentMode); ddProvince.Items.Clear(); ddProvince.Items.Add(new ListItem("--Select Province--", "")); ddCity.Items.Clear(); ddCity.Items.Add(new ListItem("--Select City--", "")); int CountryVal = 0; if (ddCountry.SelectedItem.Value!="") { CountryVal = Convert.ToInt32(ddCountry.SelectedItem.Value); } ddProvince.AppendDataBoundItems = true; try { System.Data.DataTable dsProvinces = new System.Data.DataTable(); WcfCustomersVB.ServiceCustomer client = new WcfCustomersVB.ServiceCustomer(); dsProvinces = client.GetProvinces(CountryVal); ddProvince.DataSource = dsProvinces; ddProvince.DataTextField = "ProvinceName"; ddProvince.DataValueField = "ProvinceID"; ddProvince.DataBind(); if (ddProvince.Items.Count > 1) { ddProvince.Enabled = true; } else { ddProvince.Enabled = false; ddCity.Enabled = false; } } catch (Exception ex) { throw ex; } }
protected void SetupProvinceDD(int SelectedProvinceVal = 0, int CountryID = 0) { DropDownList ddProvince = (DropDownList)dvAddress.FindControl("ddProvince" + strCurrentMode); ddProvince.AppendDataBoundItems = true; try { System.Data.DataTable dsProvince = new System.Data.DataTable(); WcfCustomersVB.ServiceCustomer client = new WcfCustomersVB.ServiceCustomer(); dsProvince = client.GetProvinces(CountryID); ddProvince.DataSource = dsProvince; ddProvince.DataTextField = "ProvinceName"; ddProvince.DataValueField = "ProvinceID"; ddProvince.DataBind(); ddProvince.SelectedValue = SelectedProvinceVal.ToString(); } catch (Exception ex) { throw ex; } }