asp.net.ph

Skip Navigation Links

Specifying List Layout in a DataList Control

Controls You Can Use on Web Forms   ASP.NET Data Controls   DataList Control


By default, the DataList displays its contents onto a single column table.

The DataList, though, includes a RepeatColumns property that can be set to render the list items in any number of columns, and a RepeatLayout property that can be set to render its contents in either Table or Flow mode.

  • If this property is not set, or is set to Table, the items in the list are rendered into an HTML <table> element.
  • If this property is set to Flow, the items in the list are rendered inline with the document flow as HTML <span> elements separated by spaces.

Flow mode is suitable for simple layouts, while Table mode affords more precise control over layout and allows the use of table attributes, such as CellSpacing, CellPadding and GridLines.

To specify column count and layout

  1. Include the RepeatColumns and RepeatLayout property within the opening tag of the DataList control.
    <asp:datalist id="myList" runat="server"
       repeatcolumns=3 repeatlayout="flow">
  2. If you are setting the property in code, use the RepeatLayout enumeration, as shown below.
    myList.RepeatLayout = RepeatLayout.Flow;
DataListRepeatLayout.aspx
Run Sample | View Source

NOTE: When not specified, RepeatLayout defaults to Table.

See Also

Adding DataList Controls to a Web Forms Page   Specifying List Direction in a DataList Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note