16.7. Selecting a Web Control to Display Data
ASP.NET developers have an overflowing toolbox of controls to choose from梞any with overlapping functionality. Table 16-6 offers some recommendations for selecting a control, or combination of controls, to handle frequently encountered Web page tasks. Some of the suggested controls have been introduced in this chapter; but for other important ones, such as the GridView, DetailsView, and FormView, you should refer to an in-depth ASP.NET 2.0 book or reference source.
Table 16-6. Controls Recommended for Typical Web Page Applications
Display multiple data records in a spreadsheet or grid format.
GridView. Provides sorting, pagination, and editing. Permits controls to be embedded in cells. Performance can be slow, so use only when these features are required. If displaying data is the only objective, use the DataList or Repeater.
Display multiple data records in a custom format using simple controls.
DataList or Repeater. Use the DataList if editing and event handling is required. Use the Repeater strictly to display data in a repeated format.
Display a parent-child relationship between data.
ListBox or DropDownList and a GridView. See Figure 16-13 on page 779.
Display a hierarchical view, such as a directory or XML elements.
treeView. Allows nodes to be expanded to display data on lower level.
View, edit, or delete data, one record at a time.
DetailsView or FormView.
Web page with multiple sections or one that steps through a process in multiple steps.
Use multiple panels as containers for simple controls. Panels in ASP.NET 2.0 include a scrolling capability for IE browsers.