asp.net.ph

Skip Navigation Links

Specifying List Direction in a DataList Control

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


By default, the DataList displays a single column in which the contents are rendered in a top to bottom sequence.

The DataList, though, includes a RepeatColumns property that can be set to render the list items in any number of columns, and a RepeatDirection property that can be set to render the items in either vertical or horizontal order.

For instance, speciying three columns with repeat direction set to Horizontal renders a list of items shown below:

1 2 3
4 5 6
7 8  

Vertical layout for the same items results in the following:

1 4 7
2 5 8
3 6  

To specify column count and ordering:

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

NOTE: When not specified, RepeatDirection defaults to Vertical.

See Also

Adding DataList Controls to a Web Forms Page   Specifying List Layout 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