//Load City #region [Load City] private void LoadCityDropDown(string p) { try { if (DDL_Country.SelectedValue.Equals("Select") && DDL_Country.SelectedValue.Equals("")) { msgBox.ShowMessage("Please Select State First !!!", "Information", UserControls.MessageBox.MessageStyle.Critical); } else { DDL_City.DataTextField = "name"; DDL_City.DataValueField = "id"; DataSet ds = ViewState["DatasetAll"] as DataSet; DataView dv = new DataView(ds.Tables["City"]); dv.RowFilter = "sid = " + p; DDL_City.DataSource = dv.ToTable(); DDL_City.DataBind(); DDL_City.Items.Insert(0, new ListItem(" Select ", "0")); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//City protected void LoadCityCombo() { int intStateID; bool blnCheck = int.TryParse(DDL_State.SelectedIndex.ToString(), out intStateID); var query = (from m in ObjEntity.Cities where m.StateID == intStateID select m).ToList(); DDL_City.DataSource = query; DDL_City.DataTextField = "CityName"; DDL_City.DataValueField = "CityID"; DDL_City.DataBind(); DDL_City.Items.Insert(0, new ListItem("--Select--", "0")); }
public void Bind_ddlCity() { cn.Open(); SqlCommand cmd = new SqlCommand("select * from tblDistrict where StateId ='" + DDL_State.SelectedValue + "'", cn); SqlDataReader dr = cmd.ExecuteReader(); DDL_City.DataSource = dr; DDL_City.Items.Clear(); DDL_City.DataTextField = "District"; DDL_City.DataValueField = "DistrictId"; DDL_City.DataBind(); cn.Close(); DDL_City.Items.Insert(0, new ListItem("--Please Select District--", "0")); }