Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 27th, 2004, 09:41 AM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataList Binding

I am trying to create a drill down report using DataList for the top level and embedding another data list for the secondlevel in the selected item template. The second datalist has datasource property set in the web form itself. This works fine

On the click of the second level i need to show a third level. For this I have tried to bind the second datalist at runtime in the DataList_ItemCommand function by setting the datasource property to the same call as in the web form. But this gives me an an error - Object Reference Not Set to an Instance of an object..

While debugging i can see the data coming out as an Arraylist but the minute I say DataList.DataSource = getData() I get the error...

Any help will be appreciated..

Thanks

 
Old May 1st, 2004, 07:39 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The problems is that you can't reference a repeated control directly in the code behind. Here's what you might try doing:

Somewhere in your 2nd level datalist, you have a button/link to drill down to the third level. This control should specify the event handler for its click event. Within the event handler, you could reference the event "sender" (the button) and from there work your way back to the DataListItem in which that button lives by using "Parent". The button's parent should be the DataListItem. Then you can access the necessary control within the DataListItem (might use FindControl for this) to get the information you need to pass to the getData() method in order to create the necessary data for the 3rd level datalist. Also, if you are using the DataKeys part of a datalist, then you can use that for your drill down information.

This is a classic case where you can't work with explicit class instances of a control that is in the markup because the control is repeated. The name you provide in the markup for that control will not exist in the codebehind because the control is a child of the repeating control. You need to work with relative objects.

Hope this helps.

Peter
-------------------------
Work smarter, not harder





Similar Threads
Thread Thread Starter Forum Replies Last Post
Datalist webnathan Oracle 1 October 20th, 2008 03:46 AM
Datalist inside datalist amit.jagtap ASP.NET 2.0 Professional 1 September 4th, 2007 05:03 AM
datalist sarah lee ASP.NET 1.0 and 1.1 Basics 0 October 18th, 2006 02:49 PM
DataList in DataList acko ASP.NET 1.0 and 1.1 Professional 3 July 9th, 2004 05:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.