mostlylucid

scott galloway's personal blog...
posts - 897, comments - 700, trackbacks - 11

My Links

News

Archives

Post Categories

Misc. Coding

Nested Data Bound List Controls in ASP.NET

This article (which pretty much constantly seems to be down for me at the moment) presents an interesting was to nest Repeaters etc... in ASP.NET, now I have never used this approach - and I have no idea what method is best (and I suck at writing so, I'll probably update this a LOT). What I generally do is use the OnItemDataBound event to bind child tables on to the nested repeater to do this you simple create an ASPX page with a repeater into which you nest a second repeater. 
In the first repeater, you use the OnItemDataBound event (ItemDataBound from the code-behind) to pull out a DataTable using a DataRelation and bind it on to the 'child' repeater...see the project for a complete implementation using Northwind.
I've made the complete project  avaialble here.
UPDATE: Sorry, I've had to pull the source for now, having major problems with the .TEXT editor...hmm...anyway, feel free to download the project and have a dig around, happy to answer any queries!

Print | posted on Monday, November 24, 2003 10:23 PM | Filed Under [ .NET ASP.NET Code Snippets ]

Feedback

Gravatar

# re: Nested Data Bound List Controls in ASP.NET

Why is it that everyone gets nested repeaters to work but me? Most of the code sanmples I found do not wire up any events to do the data binding of the child repeater. So, when I go to my page, I get no content from the child repeater.

Looking at your code, you handle the child repeater binding in the ItemDataBound event of the parent. Other code I've seen uses the ItemCreated. But when I use those functions, I can't find the child repeater control using FindControl().

Ever experienced this?

Thanks,
Jason Capriotti
JCapriotti@directs.com
1/13/2004 11:13 PM | Jason Capriotti
Gravatar

# re: Nested Data Bound List Controls in ASP.NET

Yup, always had the best results from using ItemDataBound...
1/13/2004 11:45 PM | Scott Galloway
Gravatar

# re: Nested Data Bound List Controls in ASP.NET

Off the top of your head... can you think of why the child repeater isn't found using FindControl() inside of ItemDataBound?

For example, Repeater rep2 = e.Item.FindControl("Repeater2") for me returns null. Maybe I just need some sleep... :)
1/14/2004 2:39 AM | Jason Capriotti

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 4 and 8 and type the answer here:

Powered by: