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

S

Suresh Kojhani

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.........
 
A

Anushi

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top