开发者

Paginate generate number

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜