Sam thota

Sam thota

  • NA
  • 2
  • 448

how to bind drop down lists in c#?

Jan 28 2019 1:56 AM
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)