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.
- Include the RepeatColumns and RepeatLayout property within the opening tag of the DataList control.
<asp:datalist id="myList" runat="server"
repeatcolumns=3 repeatlayout="flow">
- If you are setting the property in code, use the RepeatLayout enumeration, as shown below.
myList.RepeatLayout = RepeatLayout.Flow;
NOTE: When not specified, RepeatLayout defaults to Table.
Adding DataList Controls to a Web Forms Page Specifying List Direction in a DataList Control