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,
if (e.Row.RowType == DataControlRowType.Footer)
e.Row.Cells.Text = (GridView1.PageIndex + 1) + " of "
That’s it. View the GridView control and you should see the page count visible as shown below