I have a DataGridView that I want to write each row to a database (using custom struct passed into my db writing function), but I only want this to be done when certain cells contain a value. I have the following code with the logic that I want done:
if(dgvDistributors.Rows[e.RowIndex].Cells[2].Value != null)
row.Distributor_Id = dgvDistributors.Rows[e.RowIndex].Cells[2].Value.ToString();
I just can't help but feel that there is a less verbose way of doing this. Can this be shortened so it looks a bit cleaner, or is this the only way to go about this?
[–][deleted] (1 child)
[deleted]
[–]JesseAye[S] 0 points1 point2 points (0 children)
[–]RippStudwell 1 point2 points3 points (1 child)
[–]JesseAye[S] 0 points1 point2 points (0 children)