title: DataGridview Combobox display from datasource
body: <p><a href="https://i.stack.imgur.com/kCzmz.png" rel="nofollow noreferrer">FORM IMAGE</a>     </p>
  
  <p>I have two tables in my database </p>
  
  <ol>
  <li>datatable</li>
  <li>kar</li>
  </ol>
  
  <p>datatable have two columns Product, Producttype. kar table also have two columns type, tax.</p>
  
  <p>In my form I have a Datagridview with 3 columns Productname, type, tax. </p>
  
  <p>Productname column is datagridviewcomboboxcolumn which display all the product from datatable.    `</p>
  
  <pre><code>public Form5()
      {
          InitializeComponent();
      }
  
      private void Form5_Load(object sender, EventArgs e)
      {
          this.datatableTableAdapter.Fill(this.myBillDataSet.datatable);
          dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing);
  
      }
  
      private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
      {
          ComboBox combo = e.Control as ComboBox;
          if (combo != null)
          {
              combo.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);
              combo.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged);
          }
      }
      string item = null;
      private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
      {
          SqlConnection con = new SqlConnection(@"Data Source=ZEE-PC\SQLEXPRESS;Initial Catalog=MyBill;Integrated Security=True");
  
          ComboBox cb = (ComboBox)sender;
          item = cb.Text;
          if (item != null)
          {
              SqlCommand cmd = new SqlCommand("select Producttype from datatable where product=@pro", con);
  
              cmd.Parameters.AddWithValue("@pro", item);
              con.Open();
              string val = cmd.ExecuteScalar().ToString();
              con.Close();
  
  
              SqlCommand cmd2 = new SqlCommand("select tax from kar where type=@pro2", con);
  
              cmd2.Parameters.AddWithValue("@pro2", val);
              con.Open();
              string val2 = cmd2.ExecuteScalar().ToString();
              con.Close();
          }
  
      }
  </code></pre>
  
  <p>when user select any product from dropdown the type and tax column will display the value. I am getting the values but not able to display in gridview cell</p>