How can I set item count value per coloumn in DataList ItemTemplate?
I want to set my DataList control to have only 7 items visible in each column after DataBind.
Let's say' if I have 18 items in the data source; DataList should be rendered as 3 colums.
1st column will have first 7 items. 2nd column will have items from 8 to 15 3rd column will have items from 16 to 18
How can I set th开发者_运维百科e item count per column for each itemTemplate?
Take a look onto DataList.RepeatColumns
property:
DataList1.RepeatColumns = 3;
DataList1.RepeatDirection = RepeatDirection.Vertical;
It sounds like you're talking about limiting the rows, which you can do in your datasource before you bind.
If you are binding to a DataSet or a DataTable, you can create a DataView and filter the data to a subset of rows choosing the seven that you wish to display.
Or perhaps you're looking to page your data? In that case you'll set your DataList's PageSize to 7. (see this article for more: https://web.archive.org/web/20211020121644/https://www.4guysfromrolla.com/articles/081804-1.aspx)
精彩评论