0

I have a datagridview with one DataGridViewComboBoxColumn column and a button Submit outside datagridview which is updating all the data from datagridview in the database table. I would like to check if all the rows of combobox column is updated. In short I do not want an empty field in the DataGridViewComboBoxColumn.

In my submit button click event I am looping through all the rows of datagridview like the example shown below, and fetching value of each of the cell.

foreach (DataGridViewRow rw in dataGridView1.Rows)
{
  rw.Cells["Label"].Value.ToString();
  ...
}

Before updating the data I would like to validate the DataGridViewComboBoxColumn column to check it is not empty.

Arti
  • 2,993
  • 11
  • 68
  • 121
  • So what is the problem with your approach? I assume that you are actually trying to use: `if(String.IsNullOrEmpty(rw.Cells["Label"].Value.ToString())){}` – Tim Schmelter Jan 16 '15 at 10:36
  • This [link](http://msdn.microsoft.com/en-us/library/ms404353%28VS.80%29.aspx) may be useful for you – Tijo Tom Jan 16 '15 at 10:42
  • `if(String.IsNullOrEmpty(rw.Cells["Label"].Value.ToString())){}` would check for a single value at a time. I want to check values of combobox column of entire datagrid. – Arti Jan 16 '15 at 10:54

0 Answers0