Summary
The topic covered in this chapter is quite narrow, focusing only on the use of nested list controls in ASP.NET pages. However, as you've seen, there are plenty of issues to understand, several interesting problems to solve, and a great many options for how to go about the process.
This chapter describes how to use a DataSet instance or a DataReader instance and discusses the performance implications. It also shows how you can perform the binding declaratively to a function or by handling the ItemDataBound event and generating the row set you need that way. And, as mentioned previously, you can mix and match the techniques and the data sources in almost any combination to achieve the desired end result.
As well as addressing four basic techniques, this chapter looks at the nature of the objects that are available in the event handlers, such as the DataGridItem and DataListItem objects. It is vital that you understand what they offer and how to get the most from them. When you nest list controls, which event is being raised and how to handle it can quickly become confusing.
One issue that is mentioned a couple times in this chapter and that often causes problems as you develop pages that use complex combinations of list controls is that you must be sure your event handlers test what type of row they are handling. Bear in mind that the FindControl method cannot detect errors in your code at compile time because it only searches for controls at runtime and silently returns null (Nothing in Visual Basic .NET) if it can't find the control it's looking for. The result is a runtime error that can be hard to track down.
This chapter finishes up with a look at how a combination of list controls, in this case a DataList control and a DataGrid control, can be used to build collapsible master/detail pages with very little effort. And, along the way, this chapter discusses more ways for detecting the source of events and postbacks and managing the edit process inside a list control.