Using the DataList Control

The DataList control is another template-based control, with the addition that you can specify different methods for repeating the templates to display all of the items. Table 20-7 describes the templates that the DataList control supports.

image

Listing 20-11 shows a DataList control with the ItemTemplate and AlternatingItem templates defined.

Listing 20-11. The DataList control example

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DataListDemo.aspx.cs" Inherits="WebApp.DataListDemo" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ...

Get Applied ASP.NET 4 in Context now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.