开发者

Paginate generate number

开发者 https://www.devze.com 2023-02-11 01:11 出处:网络
I want to add page number in my application, like 1 2 3 4. My paginated class code is: public bool HasPreviousPage

I want to add page number in my application, like 1 2 3 4. My paginated class code is:

public bool HasPreviousPage
{
    get
    {
        return (PageIndex > 0);
    }
}
public bool HasNextPage
{
    get
    {
        return (PageIndex+1<TotalPages);
    }
}

This code generates link and goto next page, but can't display pag开发者_运维百科e number.


Add this property:

public IEnumerable<int> Pages
{
    get
    {
        for(var page=1; page <= TotalPages; pages++)
            yield return page;
    }
}

You could use it for rendering the pages in your page (i.e. using a repeater).

Hope it helps.

0

精彩评论

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