ADO.NET 101: Data Rendering with a DataGrid Control
(Page 1 of 7 )
This tutorial explains how to use an iterative RAD technique for displaying the data from a DataReader. It offers flexible, free form formatting.
Introduction
This how-to tutorial describes displaying the data from a DataReader using the DataGrid Iterative data bound control. In earlier tutorials displaying data using the data bound RepeaterControl and a DataList control were described. This tutorial is self-contained like the others, however, the reader will find it helpful to review the earlier tutorials here and here, which were related to the data being retrieved using the DataReader.
The iterative RAD technique described in this tutorial offers flexible, free form formatting of displayed data. When the controls are bound to a data source, the three controls Repeater, DataList, and DataGrid loop through the data row by row, and apply a template (html) in rendering on a row by row basis. Each of the controls has its own way of formatting the data. In this tutorial the several ways that data can be formatted is described.
DataReader is unbeatable for fast retrieval of data from a database. However it is only suited for Read-only, Forward- only type of data retrieval. The iterative controls can fire specialized events. In this tutorial we are only looking at binding the data to the DataReader and configuring the control. Also, data retrieved using a DataReader cannot be sorted; more on this later.
Iterative ControlsThe following picture shows the three controls in VS 2003 IDE's toolbox. The DataList and DataGrid icons show intuitively that they are related to data.

What makes the DataGrid such a flexible tool is the large number of properties and methods available for the designer as seen in the following class view for DataGrid.

Next: Displaying Data from DataReader with a DataGrid Control >>
More ASP Articles
More By Jayaram Krishnaswamy