Continuing my ASP.NET GridView Tips and Tricks series, this post shows how to display the page count in an ASP.NET GridView control
In one of our previous articles, we saw how to Highlight the current page in an ASP.NET GridView pager. Let us extend the example, to show the page count too.
The first step is to set the ShowFooter property to true and add a RowDataBound event to the GridView, as shown below
Next write the following code in the GridView_RowDataBound event
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = (GridView1.PageIndex + 1) + " of "
+ GridView1.PageCount;
}
}
That’s it. View the GridView control and you should see the page count visible as shown below
Tweet
2 comments:
Very good article. Keep up the good work.
ok nice
Post a Comment