title: How to add combo box items from SQL db?
body: <p>I need to add the items to combo box from <code>SQL</code> db  .In my form am having 1 combo box(for items) and 1 <code>textbox</code> (for values). I need to load items to both from DB table and the value of <code>textbox</code> should be selected according to value of combo box.</p>
  
  <p>eg:</p>
  
  <pre><code>combobox           textbox  
  --------------------------
   Items          price  
   sss             100       
   ddd             140  
   fff             220
  </code></pre>
  
  <p>The textbox value should be selected automatically when combobox value is selected.</p>
  
  <pre><code>private void Form4_Load(object sender, EventArgs e)
          {
              con = new SqlConnection("data source=PC\\SQLEXPRESS;integrated security=true;Initial catalog=MyDB");
              BindData1();
  }
   public void BindData1()
          {
  
  
              con.Open();
              string strCmd = "select Items from tblbill";
              SqlCommand cmd = new SqlCommand(strCmd, con);
              SqlDataAdapter da = new SqlDataAdapter(strCmd, con);
              DataSet ds = new DataSet();
              da.Fill(ds);
              cmd.ExecuteNonQuery();
              con.Close();
  
              comboBox1.DisplayMember = "items";
              comboBox1.ValueMember = "items";
              comboBox1.DataSource = ds.Tables[0];
  
              comboBox1.Enabled = true;
  
          }
  
   private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
          {
  
              con.Open();
             string sel = comboBox1.SelectedItem.ToString();
  
  
  
             SqlCommand cmd = new SqlCommand("select price from tblbill where items=" + comboBox1.SelectedValue, con);
  
              SqlDataReader dr = cmd.ExecuteReader();
              while (dr.Read())
              {
                  p = dr[0] as string;
                  //department = reader[1] as string;
  
              }
  
              textBox1.Text = p;
              con.Close();
          }
  </code></pre>
  
  <p>My combobox is filled with items from <code>tblbill</code> but can't able to display price value in <code>textbox</code> according to selection in <code>combobox</code>.</p>
  
  <p>Please help me</p>