I recently had a need to display some hierarchical data in one of my report pages at work. I wanted to use the nested repeater method, but wasn't quite sure how to implement it efficiently. Luckily I found this great knowledge base article from Microsoft called: Display Hierarchical Data by Using Nested Repeater Controls and Visual C# .NET
I try to use the SqlDataReader extensively, but hitting the database for each record in a nested repeater control would not be a sound solution. This is where the disconnected objects of the .NET framework come in handy, and more specifically; the DataSet and DataAdapter. I'll provide a quick rundown here of the solution, but reference the Microsoft article for a full explanation.
Note: I'm bypassing the creation of the nested repeater markup for simplicity.
Create one DataSet and two DataAdapter objects - one for each result set that you'll obtain from the database.
After each result set is returned, use the DataAdapter to fill the DataSet.
Your DataSet will now contain two tables (one for each query that was returned), and with those tables, you will make a relation to link the tables.
Simply bind your parent repeater control, and you're on your way.
There was one thing in the article that I was unsure of, and here is the code from the .aspx: