void bindCity(string state) { con.Open(); SqlCommand cmd = new SqlCommand("select intState_id from State_Master where txtState='" + state + "'", con); string stateId = Convert.ToString(cmd.ExecuteScalar()); con.Close(); ds1 = new DataSet(); string x1 = Convert.ToString(stateId); ds1 = countries.GetCity(x1); ddlcity.DataSource = ds1; ddlcity.DataBind(); ddlcity.Items.Insert(0, "Select City"); ddlcity.Items.Add("Other City"); }
protected void bstate_SelectedIndexChanged(object sender, EventArgs e) { string x1 = Convert.ToString(bstate.SelectedValue); ds1 = countries.GetCity(x1); if (ds1.Tables[0].Rows.Count > 0) { for (int i = 1; i <= ds1.Tables[0].Rows.Count; i++) { bcity.Items.Add(""); bcity.Items[i].Text = ds1.Tables[0].Rows[i - 1]["CityName"].ToString(); bcity.Items[i].Value = ds1.Tables[0].Rows[i - 1]["CityID"].ToString(); } } }
protected void ddlstate_change(object sender, EventArgs e) { ds = new DataSet(); string x1 = Convert.ToString(ddlstate.SelectedValue); ds = countries.GetCity(x1); ddlcity.DataSource = ds; ddlcity.DataBind(); ddlcity.Items.Insert(0, "Select City"); ddlcity.Items.Add("Other City"); }