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.Controls; //Will Find table tbl.Rows.Cells.Add(infocell);
This line needs more exp as i think:
Table tbl = (Table)row.Cells.Controls; //Will Find table
row = will have TopRow
it has cells collection cells means 1 2 3 4 5 6 and out of it controls means that <table> just add one <td> that’s it by using Tablecell..