Jitendra Shekhawat

Jitendra Shekhawat

  • NA
  • 1.7k
  • 16.8k

How toshow name and insert values (name's ID ) from combobox

Mar 30 2017 1:44 AM
c# Windows Forms.
 
 
 
public void Load()
{
DataRow dr;
con.Open();
SqlCommand cmd = new SqlCommand("select * from city", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
dr = dt.NewRow();
dr.ItemArray = new object[] { 0, "--Select City--" };
dt.Rows.InsertAt(dr, 0);
comboBoxunit.ValueMember = "city_ID";
comboBoxunit.DisplayMember = "city";
comboBoxunit.DataSource = dt;
con.Close();
}
 

Answers (5)