This documentation is archived and is not being maintained.

DataList.RepeatLayout Property

Gets or sets whether the control is displayed in a table or flow layout.

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

public virtual RepeatLayout RepeatLayout { get; set; }
<asp:DataList RepeatLayout="RepeatLayout" />

Property Value

Type: System.Web.UI.WebControls.RepeatLayout
A value that specifies whether the control is displayed in a table or in flow layout.


The specified value is not one of the supported RepeatLayout values.

Use the RepeatLayout property to specify whether the items in the DataList control are displayed in a table. The only RepeatLayout values that are supported by the DataList control are Table and Flow.

If this property is set to RepeatLayout.Table, the items in the list are displayed in a table. If this property is set to RepeatLayout.Flow, the items in the list are displayed without a table structure.

When the DataList control is displayed in a table, you can use the GridLines property to specify a grid line style.

The following code example demonstrates how to use the RepeatLayout property to specify the layout style 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"
<html xmlns="" >
   <script runat="server">

      ICollection CreateDataSource() 

         // Create sample data for the DataList control.
         DataTable dt = new DataTable();
         DataRow dr;

         // Define the columns of the table.
         dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
         dt.Columns.Add(new DataColumn("StringValue", typeof(String)));
         dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
         dt.Columns.Add(new DataColumn("ImageValue", typeof(String)));

         // Populate the table with sample values.
         for (int i = 0; i < 9; i++) 
            dr = dt.NewRow();

            dr[0] = i;
            dr[1] = "Description for item " + i.ToString();
            dr[2] = 1.23 * (i + 1);
            dr[3] = "Image" + i.ToString() + ".jpg";


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

      void Page_Load(Object sender, EventArgs e) 

         // Load sample data only once, when the page is first loaded.
         if (!IsPostBack) 
            ItemsList.DataSource = CreateDataSource();


      void Button_Click(Object sender, EventArgs e) 

         // Set the repeat direction based on the selected value of the
         // DirectionList DropDownList control.
         ItemsList.RepeatDirection = 

         // Set the repeat layout based on the selected value of the
         // LayoutList DropDownList control.
         ItemsList.RepeatLayout = (RepeatLayout)LayoutList.SelectedIndex;

         // Set the number of columns to display based on the selected
         // value of the ColumnsList DropDownList control.
         ItemsList.RepeatColumns = ColumnsList.SelectedIndex;

         // Show or hide the gridlines based on the value of the
         // ShowBorderCheckBox property. Note that gridlines are displayed
         // only if the RepeatLayout property is set to Table.
         if ((ShowBorderCheckBox.Checked) 
             && (ItemsList.RepeatLayout == RepeatLayout.Table)) 
            ItemsList.BorderWidth = Unit.Pixel(1);
            ItemsList.GridLines = GridLines.Both;
            ItemsList.BorderWidth = Unit.Pixel(0);
            ItemsList.GridLines = GridLines.None;



<head runat="server">
    <title>DataList Example</title>

   <form id="form1" runat="server">

      <h3>DataList Example</h3>

      <asp:DataList id="ItemsList"

         <HeaderStyle BackColor="#aaaadd">

         <AlternatingItemStyle BackColor="Gainsboro">


            List of items



            Description: <br />
            <%# DataBinder.Eval(Container.DataItem, "StringValue") %>

            <br />

            Price: <%# DataBinder.Eval(Container.DataItem, "CurrencyValue", "{0:c}") %>

            <br />

            <asp:Image id="ProductImage"
                 AlternatingText='<%# DataBinder.Eval(Container.DataItem, "StringValue") %>'
                 ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImageValue") %>'



      <hr />

      <table cellpadding="5">



               Repeat direction:



               Repeat layout:



               Repeat columns:



               <asp:CheckBox id="ShowBorderCheckBox"
                    Text="Show border"
                    runat="server" />





               <asp:DropDownList id="DirectionList" 

                  <asp:ListItem Selected="True">Vertical</asp:ListItem>




               <asp:DropDownList id="LayoutList" 

                  <asp:ListItem Selected="True">Table</asp:ListItem>




               <asp:DropDownList id="ColumnsList" 

                  <asp:ListItem Selected="True">0</asp:ListItem>








      <asp:LinkButton id="RefreshButton" 
           Text="Refresh DataList" 



.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.