NullReferenceException was unhandled by usercode,
Objectreference not set to an instance of an object
The error message was shown in the following code
Public Sub Proc_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim CheckBx As new CheckBox
Dim checkBx1 as new CheckBox
Dim dgItem As DataGridItem
For Each dgItem In datagrid1.Items
CheckBx = dgItem.FindControl("Checkbox2")
CheckBx1 = dgItem.FindControl("Checkbox1")
If CheckBx.Checked Then
CheckBx1.Checked = True
CheckBx1.Checked = False
The error was occured in the if condition.
This is a common error which occurs when there is no values are there with the
associated variables/strings/other items which we are using in our code,and
checking them for the values/assigning those null values to another ones.
In the above code
This error occurs when there is no values checked or the check box checked
value is "Nothing".