列表显示为 2 列
我有一个需要在 aspx 页面上显示的动态数据列表(asp .net 集合)。我希望两列中的数据根据列表中的项目数量从左到右填充。在这种情况下,最好使用什么 Webcontrol?
I have a dynamic List (asp .net collection) of Data that I need to display on a aspx page. I want the data in two columns filling up from left to right depending on the number of items on the list. WHat webcontrol would be the best to use in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 DataList、中继器 或 GridView。这实际上是一个除了布局要求之外还需要支持哪些功能(排序、过滤、分页等)的问题(以上所有功能都可以满足您的需要)。
GridView 和 Repeater 有点重,但提供了简单的挂钩来实现更高级的功能。
更新
示例:
注意:根据您的需要进行修改,但这应该可以帮助您入门。
You can use DataList, Repeater or GridView. It's really a matter of which features do you need to support (sorting,filtering, paging, etc.) besides your layout requirements (all of the above can do what you need).
GridView and Repeater are a bit heavier but provide easy hooks for implementing more advanced features.
UPDATE
Example:
Note: Modified to your needs but this should get you started.
中继器可以在这种情况下工作,并允许您非常灵活地设计它。
CSS
ASPX
Eval("DataColumn") 将表示您想要显示的表列的名称,您可以在代码隐藏中或使用拖放数据源控件之一设置转发器的数据源。
由于“float:left”,CSS 将使数据显示为从左到右的 2 列。容器宽 300 像素,每个项目宽 150 像素,这应使其具有两列外观。
A repeater would work in this situation and allow you alot of flexibility to style it.
CSS
ASPX
Eval("DataColumn") would represent the name of the table column you wanted to display, and you can set the datasource for the repeater either in the codebehind or using one of the drag and drop datasource controls.
The CSS will make the data appear as 2 columns going left to right thanks to the "float:left". The container is 300px wide, and the items are going to be 150px each which should give it the two column appearance.