title: C# - How to populate combobox in datagridview only in certain column?
body: <p>I have a requirement to populate data in gridview as below.</p>
  <p><a href="https://i.stack.imgur.com/oCPl6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oCPl6.png" alt="enter image description here" /></a></p>
  <p>I have a table which stores all of this value. For each &quot;Destination Column&quot; and &quot;Type&quot; will be assigned value based on &quot;Source Column&quot;. But I have a problem in setting the default value for &quot;Destination Column&quot; and &quot;Type&quot;.
  Can someone give me an idea. As I have been stuck with this for whole day. Any help is highly appreciated.</p>
  <p>Below is the code.</p>
  <pre><code>string sqlMatchedData = &quot;SELECT convert(integer, 100 * SIMILARITY) AS SIMILARITY, SOURCE_NAME &quot; + 
                          &quot;FROM TB_LOOKUP_COLUMN WHERE SOURCE_NAME IN (&quot; + allColumnName + &quot;)&quot;;
  ds = databaseManager.GetData(sqlMatchedData);
  //dataGridView1.DataSource = ds.Tables[0];
  //dataGridView1.Columns[1].Visible = false;
  //dataGridView1.Columns[2].Visible = false;
  
  dt = new DataTable();
  DataRow dr;
  dt.Columns.Add(&quot;Similarity (%)&quot;);
  dt.Columns.Add(&quot;Source Column&quot;);
  //dt.Columns.Add(&quot;C&quot;);
  //dt.Columns.Add(&quot;D&quot;);
  
  foreach (DataRow row in ds.Tables[0].Rows)
  {
      dr = dt.NewRow();
      string v = row[0].ToString();
      string v1 = row[1].ToString();
      //string v2 = row[2].ToString();
      //string v3 = row[3].ToString();
  
      dr[0] = v;
      dr[1] = v1;
      //dr[2] = v2;
      //dr[3] = v3;
      dt.Rows.Add(dr);
  }
  dataGridView1.DataSource = dt;
  
  //LookupColumn
  string sqlLookupColumn = &quot;SELECT LookUpColumnID, SOURCE_NAME FROM TB_LOOKUP_COLUMN&quot;;
  DataSet dsColumn = databaseManager.GetData(sqlLookupColumn);
  DataGridViewComboBoxColumn comboLookup = new DataGridViewComboBoxColumn();
  comboLookup.DataSource = dsColumn.Tables[0];
  comboLookup.HeaderText = &quot;Destination Column&quot;;
  comboLookup.Name = &quot;Destination&quot;;
  comboLookup.DisplayMember = &quot;SOURCE_NAME&quot;;
  comboLookup.ValueMember = &quot;LookUpColumnID&quot;;
  dataGridView1.Columns.Add(comboLookup);
  comboLookup.DefaultCellStyle.NullValue = &quot;Please Select&quot;;
  
  //datatype
  string sqlDataType = &quot;SELECT DataTypeLookUpID, DATATYPE FROM TB_LOOKUP_DATATYPE&quot;;
  DataSet dsDataType = databaseManager.GetData(sqlDataType);
  DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
  combo.DataSource = dsDataType.Tables[0];
  combo.HeaderText = &quot;Type&quot;;
  combo.Name = &quot;Type&quot;;
  combo.DisplayMember = &quot;DATATYPE&quot;;
  combo.ValueMember = &quot;DataTypeLookUpID&quot;;
  dataGridView1.Columns.Add(combo);
  combo.DefaultCellStyle.NullValue = &quot;Please Select&quot;;
  </code></pre>