RepeatLayout Property

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 Overridable Property RepeatLayout As RepeatLayout
Dim instance As DataList
Dim value As RepeatLayout

value = instance.RepeatLayout

instance.RepeatLayout = value
/** @property */
public RepeatLayout get_RepeatLayout ()

/** @property */
public void set_RepeatLayout (RepeatLayout value)

public function get RepeatLayout () : RepeatLayout

public function set RepeatLayout (value : RepeatLayout)

Property Value

One of the RepeatLayout values. The default is Table.

Exception typeCondition


The specified value is not one of the RepeatLayout values.

Use the RepeatLayout property to specify whether the items in the DataList control are displayed in a table. 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="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
   <script runat="server">
      Function CreateDataSource() As ICollection 
         ' Create sample data for the DataList control.
         Dim dt As DataTable = New DataTable()
         dim dr As DataRow
         ' Define the columns of the table.
         dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
         dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
         dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))
         dt.Columns.Add(New DataColumn("ImageValue", GetType(String)))
         ' Populate the table with sample values.
         Dim i As Integer

         For i = 0 To 8 

            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"

         Next i
         Dim dv As DataView = New DataView(dt)
         Return dv

      End Function
      Sub Page_Load(sender As Object, e As EventArgs) 

         ' Load sample data only once, when the page is first loaded.
         If Not IsPostBack Then 
            ItemsList.DataSource = CreateDataSource()
         End If

      End Sub
      Sub Button_Click(sender As Object, e As EventArgs) 
         ' Set the repeat direction based on the selected value of the
         ' DirectionList DropDownList control.
         ItemsList.RepeatDirection = _
             CType(DirectionList.SelectedIndex, RepeatDirection)

         ' Set the repeat layout based on the selected value of the
         ' LayoutList DropDownList control.
         ItemsList.RepeatLayout = CType(LayoutList.SelectedIndex, RepeatLayout)

         ' 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. Note that gridlines are displayed
         ' only if the RepeatLayout property is set to Table.
         If ShowBorderCheckBox.Checked _
             And ItemsList.RepeatLayout = RepeatLayout.Table Then 

            ItemsList.BorderWidth = Unit.Pixel(1)
            ItemsList.GridLines = GridLines.Both
            ItemsList.BorderWidth = Unit.Pixel(0)
            ItemsList.GridLines = GridLines.None
         End If
      End Sub    
   <form 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") %>


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


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


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

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

© 2016 Microsoft