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.
精彩评论