Greetings,

I am working with ASP.NET 2.0 GridView. I have a GridView nested in a View control. When I select a record from the GridView I want to populate the records values by Key into a collection of TextBoxes in a second View control within my MultiView. From a scope point of view, this (in theory) should work.

Simple... or so I thought.

Let me set this up a bit more.

I have two View controls, vDisplay and vBuild. Each of these View controls are nested in a MultiView mvProducts.

When I enter vDisplay I have a GridView that displays selected data pulled from SQL Server. When I select a record from the GridView I want to load the key values into a collection of TextBox controls in vBuild View control. On the first time through my vBuild does not display the data, and I get an "Object reference not set to an instance of an object."

Now I know that means I have not instantiated or initialized a control. However, all the controls are present on the Web page.

Now here's the twist. If I navigate to my vBuild View control, then navigate back to my vDisplay View control and select a record I am successfully able to navigate to my vBuild View control with populated data.

My question, has anyone experienced this type of issue before, can anyone explain to me the order of operation for the GridView, what the page life cycle should look like, or if you have a solution.... Please share.

I thank you in advance for your thoughtful and insightful assistance.

--

Dr. Dave

I solved the issue. Because I am using an AJAX extender (specifically, the accordian extender) on the first time the page loads any ASP.NET Control inside the extender is not visable to the page until the page fully executes its life cycle.

I put a single FindControl at the point in my code behind before I attempted to populate my TextBox controls inside the extender, and it all worked.

Moral to the story, objects must be visible before you use them.

Regards

--

Dr. Dave

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.