Object reference not set to an instance of an object
This error happens when you try to use a property or call a method of an object that is null. More details:
here[
^]
A simple use of Visual studio DEBUGGER can tell you the object because of which it is happening. Just look at the stack trace and put a debugger on that line. Check the objects of that line and see if any one is null and you are trying to use that objects property. Handle the same.
Based on what you have shared above, most probably
lab
is NULL. Make sure there is a control named 'd' in the row.
Also, it may be this error is for grid header where no label 'd' control is present.
If so, try:
DataControlRowType rtype = e.Row.RowType;
if (rtype == DataControlRowType.DataRow && rtype != DataControlRowType.Footer && rtype != DataControlRowType.Header)
{
}
A simple use of breakpoint in the method in DEBUG mode will clear all the doubts and possible fix.