3
Answers

how to bind drop down lists in c#?

Sam thota

Sam thota

6y
528
1
private void comboBoxComNS_SelectedIndexChanged(object sender, EventArgs e)//country
{
ModelBind();
string str = Convert.ToString(comboBoxComNS.SelectedValue);
SqlCommand cmd = new SqlCommand("Select MODELNUM from TBL_MODEL where COMPID=@compid", conn);
cmd.Parameters.AddWithValue("@compid", str);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Modelnew");
comboBoxMNS.DataSource = ds.Tables["Modelnew"];
}
 
Answers (3)