ADO.NET 101: Data Rendering with a DataList Control Introduction - Displaying Data from DataReader with a DataList Control
(Page 2 of 5 )
On the DataListExample.aspx page, drop the DataList Control by clicking and dragging it to the design pane of the web page as shown. The properties window is also shown in this picture. By default it will be named DataList1. But it is better to change it to some meaningful name.

When the control is placed on the web form, the following code is added to the web page's HTML between the <form></form> tags as shown here with some default style information.

In the design pane you may right click and add templates, of which the ItemTemplate is a required (must) item. If you right click and pick the Edit Template drop down menu, the various templates on the DataList control can be edited.
IDE related details of DataList ControlIn a manner very similar to the RepeaterControl, by just typing in a <, the intellisense's drop down menu will appear with a list of tags that can be inserted as shown here.

The header and footer templates serve the purpose of providing the information that is suggested by their names. For example, these include the column names of a table in the header and some aggregate information, or a date in the footer. The ItemTemplate is where the row after row of data comes in. The Header and Footer templates are rendered only once since they are needed only once. If they are not defined, they are not rendered. The Alternating ItemTemplate is a part of the same ItemTemplate, but helps with optionally rendering the alternate rows of ItemTemplate for better readability of data. Again, it is rendered only if it is defined, not otherwise. The ItemTemplate is mandatory, however.
Configuring the ItemTemplateThis is an important step because ItemTemplate is a required item. This part of the control is what displays the main data from the database.
Next: Data from a DataReader >>
More Database Articles
More By Jayaram Krishnaswamy