title: Set default value in DataGridView combo box
body: <p>I'm using <code>DataGridView</code> in windows form to allow the user to add n numbers of rows with values enter by the user. One of the column of <code>DataGridView</code> contains combo box, which is displaying its items by using database.</p>
  
  <p>I'm using the following code in Load event to connect <code>DataGridViewComboBox</code> with database :</p>
  
  <pre><code>private void PurchaseMaster_Load(object sender, EventArgs e)
  {
      DataTable dt = itemBAL.GetTable();
      bindingSource1.DataSource = dt;
      ItemName.DataSource = bindingSource1;
      ItemName.DisplayMember = "Name";
      ItemName.ValueMember = "ItemId";
      ItemName.DataPropertyName = "ItemId";
      ItemName.AutoComplete = true;
      ItemName.DefaultCellStyle.NullValue = dt.Rows[0][1].ToString();
      ItemName.DefaultCellStyle.DataSourceNullValue = dt.Rows[0][0].ToString();
  }
  </code></pre>
  
  <p>But whenever I not select any value from <code>DataGridViewComboBox</code> and click on save button I find <code>null</code> value in the table corresponding to <code>DataGridViewComboBox</code> value. </p>
  
  <pre><code>foreach (DataGridViewRow row in dataGridView1.Rows)
  {
      if (row.IsNewRow)
          continue;
  
      DataRow dtRow = dt.NewRow();
      for (int i = 0; i &lt; dataGridView1.Columns.Count; i++)
          dtRow[i] = row.Cells[i].Value == null ? DBNull.Value : row.Cell[i].Value;
      dt.Rows.Add(dtRow);
  }
  </code></pre>
  
  <p>Could anyone please tell me why I'm getting null value in database for <code>DataGridViewcombobox</code> defult value, despite of using <code>DataSourceNullValue</code> property?</p>