Wednesday, November 5, 2008

Including page in front of grid view page numbers

here is the code for including 'page' text infront of the grid view page numbers

protected void GridView1_PreRender(object sender, EventArgs e)
{
GridView grid = (sender as GridView);

if (grid != null)
{
GridViewRow pagerRow = grid.BottomPagerRow;

if (pagerRow != null && pagerRow.Visible)
{
Table pagerTable = (pagerRow.Cells[0].Controls[0] as Table);

pagerTable.CssClass = "PagerTable";

Label pageText = new Label();

pageText.Text = "page ";
pageText.CssClass = "PagerLabel";
pagerRow.Cells[0].Controls.AddAt(0, pageText);
}
}
}

And Css style is:
.PagerLabel
{
float: left;
font-weight: normal;
padding-left: 5px;
padding-top: 3px;
}

.PagerTable
{
float: left;
}


best regards,
Jagan Patnam

No comments: