ADO.NET 101: Data Rendering with a Repeater Control Introduction
(Page 1 of 4 )
This tutorial series describes displaying the data from a DataReader using Iterative data bound controls. This particular article covers displaying data using the data bound control Repeater, which allows a certain degree of flexibility for formatting.
This how-to tutorial describes displaying the data from a DataReader using Iterative data bound controls. In the first SqlDataReader tutorial, data from a DataReader was displayed mostly by resorting to the Response.Write() method of a web page, or using the AddItem() method of a list control.
In the second tutorial, the data was displayed by using standard server controls such as Textbox, ListBox, DropDownList, and Table. In this tutorial displaying data using the data bound control Repeater will be described. If you review the previous tutorials you would observe that the rendered display did not offer any built-in flexibility for formatting. The most you could do was to wrap it in a suitable HTML tag which necessitated adding extra tags in the code.
The iterative technique described in this tutorial offers the RAD technique of 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. You will see that setting up an iterative control is slightly harder than using any of the server controls.
There are differences between each of these controls, so you should make your choice based on your requirements. For example, if paging is one of the requirements, DataGrid is the best choice as the two others are not amenable to paging.
We have seen that DataReader is best suited for the Read-only, Forward- only type of data retrieval. Hence, when using these controls we are not using the specialized events that can be fired by objects on these controls. However, this tutorial shows the basics of binding data to these controls using the DataReader.
Iterative ControlsThe next picture shows the three iterative controls as you find them in the collection of web form controls.

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