Object reference not set to an instance of an object - ASP.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itsvineeth209
    New Member
    • Mar 2008
    • 4

    Object reference not set to an instance of an object - ASP.NET

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullRefe renceException: Object reference not set to an instance of an object.

    Source Error:


    Line 236: GridViewRow row = GridView1.Rows[i];
    Line 237:
    Line 238: bool isChecked = ((CheckBox)row. FindControl("Ch eckBox2")).Chec ked;
    Line 239:
    Line 240: if (isChecked)


    Source File: h:\Office Works\Projects\ Sample Applications\Gr idViewVitCode.a spx.cs Line: 238


    Plz solve this problem
    Last edited by jhardman; Mar 31 '08, 06:07 AM. Reason: moved to .Net forum. ASP forum is for "classic" ASP
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    This error occurs when a control or variable you are trying to access is NULL. In this case either row is NULL or the CheckBox does not exist. Run a debugger and see which value is NULL.

    Nathan

    Comment

    • Surajs
      New Member
      • Apr 2008
      • 1

      #3
      The value in ((CheckBox)row. FindControl("Ch eckBox2")).Chec ked; might not be initialized. Please check if there is any value being taken in it. you can use break points to do it.

      Comment

      Working...