如何在 DataList ItemTemplate 中设置每列的项目计数值?
我想将 DataList 控件设置为在 DataBind 后每列中仅显示 7 个项目。
假设“如果数据源中有 18 个项目; DataList 应呈现为 3 列。
第一列将包含前 7 项。 第二列将包含 8 到 15 项 第三列将包含从 16 到 18 的项目
如何设置每个 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 the item count per column for each itemTemplate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看
DataList。 RepeatColumns
属性:Take a look onto
DataList.RepeatColumns
property:听起来您正在谈论限制行,您可以在绑定之前在数据源中执行此操作。
如果要绑定到 DataSet 或 DataTable,则可以创建 DataView 并将数据过滤到行的子集,选择要显示的七个行。
或者也许您正在寻找对数据进行分页?在这种情况下,您将 DataList 的 PageSize 设置为 7。(有关更多信息,请参阅本文:https://web.archive.org/web/20211020121644/https://www.4guysfromrolla.com/articles/081804-1.aspx)
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)