This documentation is archived and is not being maintained.

DataList.ExtractTemplateRows Property

Gets or sets a value that indicates whether the rows of a Table control, defined in each template of a DataList control, are extracted and displayed.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public virtual bool ExtractTemplateRows { get; set; }
<asp:DataList ExtractTemplateRows="True|False" />

Property Value

Type: System.Boolean
true if the rows of a Table control, defined in each template of a DataList control, are extracted and displayed; otherwise, false. The default value is false.

The contents of the DataList control are specified by using templates. Normally, you list controls that you want to display in the templates. You can also place a Table control in a template and display the rows of the table.

Use the ExtractTemplateRows property to specify whether the rows of a Table control defined in each template of a DataList control are extracted and displayed. All rows extracted from the templates of the DataList control are displayed in a single table. This allows you to create a single table from other smaller tables and still maintain the features of the DataList control.


When this property is set to true, you must provide a well-formed Table control for each template you want to include in the DataList control. Only the rows of the tables will be displayed. All other content in the template will be ignored. You must use a Table control for this feature to work properly. The System.Web.UI.HtmlControls.HtmlTable control is not compatible with this property.

When you create a cell for a Table control in a template, you can use the ColumnSpan property of the TableCell object to control the number of columns the cell spans. You can also use the RowSpan property to control the number of rows the cell spans.


The RepeatColumns, RepeatDirection, and RepeatLayout properties do not affect the appearance of the DataList control when this property is set to true.

The following code example demonstrate how to use the ExtractTemplateRows property to extract and display the rows of Table controls defined in the templates of the DataList control.


The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Page Code Model.

<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    <script runat="server">

        private ICollection CreateDataSource()
            DataTable dt = new DataTable();
            DataRow dr;

            dt.Columns.Add(new DataColumn("StringValue", 
            dt.Columns.Add(new DataColumn("PriceValue", 
            dt.Columns.Add(new DataColumn("DescriptionValue", 

            for (int i = 1; i < 11; i++)
                dr = dt.NewRow();
                dr[0] = "Item " + i.ToString();
                dr[1] = String.Format("{0:C}", (1.23 * (i + 1)));
                dr[2] = "Description for Item " + i.ToString();

            DataView dv = new DataView(dt);
            return dv;

        private void Page_Load(Object sender, EventArgs e)
            if (!IsPostBack)
                DataList1.DataSource = CreateDataSource();

<html xmlns="" >
<head runat="server">
        ExtractTemplateRows Example
    <form id="form1" runat="server">

    <h3>DataList ExtractTemplateRows Example</h3>

    <asp:DataList id="DataList1" runat="server"
        Font-Names="Arial, Helvetica"

        <HeaderStyle BackColor="LightBlue" />
        <AlternatingItemStyle BackColor="#efefef" />

        <asp:Table id="Table1" runat="server">
                    Items List

            <asp:Table id="Table2" runat="server">
                        Text='<%# Eval("StringValue") %>'>
                        Text='<%# Eval("PriceValue") %>'>
                        Text='<%# Eval("DescriptionValue") %>'>


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.