datagridview cell null or empty

124 Views Asked by At

to check datagridview cell for null value or empty I have used the following code

 if (dgvPersonnelInfo.Rows[e.RowIndex].Cells[2].Value==null )
            {

            }

but it gives me error object reference not set to an instance of an object. Is there any one to help

1

There are 1 best solutions below

0
On

Try checking to see if dgvPersonnelInfo.Rows[e.RowIndex].Cells[2] is null or not. If so then this will be the cause of your issue, as the code cannot find the value for an object that does not exist.