Murugan.com
Murugan Andezuthu Dharmaratnam

  |  HOME   |  BLOG   |  TWITTER   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  



NullReferenceException was unhandled by usercode,Objectreference not set to an instance of an object

Home   ASP.NET   NullReferenceException was unhandled by usercode,Objectreference not set to an instance of an object         


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
            Else
                 CheckBx1.Checked = False
            End If
        Next
    End Sub
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".







  |  HOME   |  BLOG   |  TWITTER   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  

Copyright 2009 @ Murugan Andezuthu Dharmaratnam