O'Reilly logo

Programming ASP.NET, 3rd Edition by Dan Hurwitz, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

DataList Control

The toolbox provides a DataList control for creating templated lists of data. A templated list is one in which you control the HTML used to render the list by defining templates: HTML that describes how to display one item in the list.

Tip

DataList controls provide simple templates; if you need precise control of the layout, consider using the Repeater control, covered below.

There are seven different templates available for defining the appearance of a DataList control, listed in Table 9-3. Of those templates, all but the ItemTemplate are optional.

Table 9-3. DataList templates

Template name

Description

AlternatingItemTemplate

Provides content and layout for every other item. If not defined, then the ItemTemplate will be used for every item in the DataList.

EditItemTemplate

Provides content and layout for the item currently being edited. If not defined, then the ItemTemplate will be used for the currently edited item.

FooterTemplate

Provides content and layout for the footer. If not defined, then the DataList will not have a footer.

HeaderTemplate

Provides content and layout for the header. If not defined, then the DataList will not have a header.

ItemTemplate

Required. Default definition for every item's content and layout.

SelectedItemTemplate

Provides content and layout for the currently selected item. If not defined, then the ItemTemplate will be used.

SeparatorTemplate

Provides content and layout for the separator between items. If not defined, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required