在数据列表中显示图像asp.net
我正在使用 datalist 来显示图像。我想显示这样的图像
**image image image** I am getting only 1 row
image image image
image image image
image image image
:三列四行。我有以下设置,但我只获得一行,如何才能每页获得 4 行?
<asp:DataList Style="border-bottom: 1px solid" ID="ImageList" runat="server"
CssClass="mytable2"
RepeatDirection="Horizontal">
背后代码:
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = productImageList.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 3;
objPds.CurrentPageIndex = CurrentPage;
cmdPrev.Enabled = !objPds.IsFirstPage;
cmdNext.Enabled = !objPds.IsLastPage;
ImageList.RepeatColumns = 5;
ImageList.RepeatLayout = RepeatLayout.Table;
ImageList.DataSource = objPds;
ImageList.DataBind();
其中productImageList是一个数据集。
I am using datalist to show images. I want to show images like this
**image image image** I am getting only 1 row
image image image
image image image
image image image
Means, three column and 4 rows. I have below setting but I am getting one row only, how can I get 4 rows per page?
<asp:DataList Style="border-bottom: 1px solid" ID="ImageList" runat="server"
CssClass="mytable2"
RepeatDirection="Horizontal">
Code behind:
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = productImageList.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 3;
objPds.CurrentPageIndex = CurrentPage;
cmdPrev.Enabled = !objPds.IsFirstPage;
cmdNext.Enabled = !objPds.IsLastPage;
ImageList.RepeatColumns = 5;
ImageList.RepeatLayout = RepeatLayout.Table;
ImageList.DataSource = objPds;
ImageList.DataBind();
Where productImageList is a dataset.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您使用的
PageSize
为 3,这意味着您的数据列表将仅显示 3 条记录。您需要选择 PageSize = 12(3 列 x 4 行)。最后,对于数据列表中的 3 列,您需要
ImageList.RepeatColumns = 3;
或根据行和列调整页面大小。Issue is that you are using
PageSize
of 3 which means your data-list will get only 3 records to display. You need to select PageSize = 12 (3 columns x 4 rows).And lastly, for 3 columns in data list, you need to have
ImageList.RepeatColumns = 3;
or adjust page size accordingly to your rows and columns.