开发者

Showing image in datalist asp.net

开发者 https://www.devze.com 2023-02-27 07:08 出处:网络
I am using datalist to show images. I want to show images like this **image image image** I am getting only 1 row

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;


        c开发者_运维技巧mdPrev.Enabled = !objPds.IsFirstPage;
        cmdNext.Enabled = !objPds.IsLastPage;

        ImageList.RepeatColumns = 5;
        ImageList.RepeatLayout = RepeatLayout.Table;
        ImageList.DataSource = objPds;
        ImageList.DataBind();

Where productImageList is a dataset.


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).

objPds.PageSize = 12;

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消