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.
For now, error in line below
CheckBox cBox = (CheckBox)contact.FindControl("cbSelect");
means that there was no control named '
cbSelect
' in the '
contact
' object.
contact.FindControl("cbSelect")
returned
null
. Now, when you try to cast it into
CheckBox
, it throw error.
Verify that the name is correct and exists in the control object contact. Put a null check too.