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

From: Val Mazur (group51a_at_hotmail.com)
Date: 06/30/04


Date: Tue, 29 Jun 2004 21:47:33 -0400

Hi,

I think objDS is not loaded and it is set to Nothing. In this case your code
would fail. Hard to say where it is disposed based on posted code. When you
page posts back it does not remember dataset,because ASP.NET is a stateless
environment.

-- 
Val Mazur
Microsoft MVP
"Alex" <Alex@discussions.microsoft.com> wrote in message 
news:2331BE4F-49AC-4596-9D2A-1680317B06B1@microsoft.com...
>I am pulling my hair out.  Please help!
>
> I have a dataset i'm using to populate a number of datagrids
>
> in the masterDataGrid_ItemCreated event handler, i have added code to add 
> a component name from the dataset.  It works perfectly when it first 
> loads.
>
> Dim Component_Name As String = 
> objDS.Tables("components").Rows(e.Item.DataSetIndex).Item("cpt_Title").ToString()
>
> When it posts back, however, i get
>
> Object reference not set to an instance of an object.
>
> I have tried having the dataset load in both the Page_Load and Page_Init 
> subs and it didn't make a difference.  Also objDS is declared as a private 
> dataset in the initial declarations (changing it to public didn't help 
> either).
>
> If anyone can at least point me in the right direction, i would appreciate 
> it.
>
> Thanks