Error:Object reference not set to an instance of an object.

Discussion in 'ASP .Net' started by Suresh Kojhani, Jul 22, 2004.

  1. I m Using PageTemplate Class In Which I have Define All my Control Like
    Textbox, Label, Dropdownlist. After That I inherit each page from This
    Pagetemplate class...When i m trying to acess the DropdownList Control
    it give me error "Object reference not set to an instance of an object."
    All Other control Behave normailly..

    Any one can Help Me.........




    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Suresh Kojhani, Jul 22, 2004
    #1
    1. Advertising

  2. Suresh Kojhani

    Anushi Guest

    Hi Suresh,
    Though you haven't provided enough details here, lemme try.
    First of all, this dropdownlist control needs databinding. Check with your
    control properties, if you are setting them right.
    Check if you are setting the table property to a valid table reference.

    Next, On a computer that has Microsoft .NET Framework 1.0 installed (and
    that does not have Microsoft Visual Studio .NET installed), when you try to
    access data using ADO Interop on an ASP.NET page that resides at an
    identical site and that is hosted on the same computer, you may receive the
    following error message:

    Exception Details: System.NullReferenceException: Object reference not set
    to an instance of an object.
    Look here for details:
    http://support.microsoft.com/default.aspx?scid=kb;en-us;810098

    As another reason, the control might just not be available to your compiler.
    If you are using the OnItemDataBound event, you have to check first whether
    the ListItemType is Item or AlternatingItem. You get the error because the
    OnItemDataBound event is first executed for the HeaderTemplate, which
    doesn't contain your control.

    Use something like this:
    Sub DataList1_ItemDataBound(sender As Object, _
    e As DataListItemEventArgs)
    If(e.Item.ItemType=ListItemType.Item Or _
    e.Item.ItemType=ListItemType.AlternatingItem) Then
    ' your code here
    End If

    Specifically for web apps, session, by default, is set to be placed as
    cookie. All I had to do is to set
    cookieless="true" in web.config

    Hope this helps.
    Anushi



    "Suresh Kojhani" <> wrote in message
    news:%23vWHN9%...
    > I m Using PageTemplate Class In Which I have Define All my Control Like
    > Textbox, Label, Dropdownlist. After That I inherit each page from This
    > Pagetemplate class...When i m trying to acess the DropdownList Control
    > it give me error "Object reference not set to an instance of an object."
    > All Other control Behave normailly..
    >
    > Any one can Help Me.........
    >
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Anushi, Jul 29, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parthiv Joshi
    Replies:
    2
    Views:
    664
    Kalyan
    Jul 2, 2004
  2. Pedro Correia
    Replies:
    0
    Views:
    607
    Pedro Correia
    Jul 25, 2003
  3. Lauchlan M
    Replies:
    1
    Views:
    2,345
    S. Justin Gengo
    Aug 18, 2003
  4. Tim Zych
    Replies:
    2
    Views:
    535
    Andy Gaskell
    May 15, 2004
  5. Replies:
    1
    Views:
    458
    Mark Rae [MVP]
    Sep 20, 2007
Loading...

Share This Page