Skip to content
April 3, 2008 / kiranpatils

Adding Total number of rows and formatting PagerRow In gridview with Default paging

Hi..i have one grid which shows data from objectconatinerdatasource. I am using Default paging which shows pager row like this

1 2 3 4 5

But i want like this

1 2 3 4 5 (Page <CURRENT PAGENUMBER> of <TotalRecords> )

How to achieve this??

Some one will say use custom paging..But i am disagree with them. Because when i can do things easily then why should i do it other way….So here is my way to do this.

1. Handle your grid’s DataBound event.

2. Handler of it will do my task.

protected void GridViewEmp_DataBound(object sender, EventArgs e)
if (GridViewEmp!= null)
//Showing Search Result Count
//Get Top Pager Row from a gridview
GridViewRow row = GV_SearchBooker.TopPagerRow;
if (row != null)

//create one Cell for adding in my current paging strip

TableCell infocell = new TableCell();
infocell.Text = ” Page ” + (GridViewEmp.PageIndex + 1).ToString() + ” of ” +                      GridViewEmp.PageCount.ToString() +
“(” + _totalrowscount.ToString() + ” Records)”;

//Getting table which shows PagingStrip

Table tbl = (Table)row.Cells[0].Controls[0]; //Will Find table                                      tbl.Rows[0].Cells.Add(infocell);


This line needs more exp as i think:

Table tbl = (Table)row.Cells[0].Controls[0]; //Will Find table

row = will have TopRow

it has cells collection cells[0] means 1 2 3 4 5 6 and out of it controls[0] means that <table> just add one <td> that’s it by using Tablecell..



Leave a Comment
  1. Manaday Mavani / Jun 2 2011 8:41 am


    Pls check this link for custom paging

    Also give your feedback.

    • kiranpatils / Jun 27 2011 2:16 am

      Hi Manaday,

      Really good article! Keep writing such stuff and do share with me!

      Happy coding! 🙂


  2. amazon coupon / Jul 31 2013 12:03 pm

    This article will help the internet users for setting up
    new website or even a blog from start to end.

  3. Ryanlame / Oct 18 2013 10:01 am

    Create custom formatting rows to GridView

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: