I am trying to use the following linq query on my datagridview:
var count = dgv_Checks.Rows.Cast<DataGridViewRow>()
.Count(row => row.Cells["SubmitToAch"]
.Value.ToString() == "True");
I allow adds to this datagridview so there is an ‘add row’ at the bottom. Every time it reaches that add row, it gives me “Object reference not set to an instance of an object.”, not only in this query but others.
Is there a way to handle linq queries or a datagridview and have it not look at this add row?
Also, how do I fix the query above to skip that row?
thanks!
Try adding a null check?