Monday, April 19, 2010

How to add Text or Server Controls(eg:Label) to GridView Pager

Add the below code to add any Text or Any other controls to GridView Pager.

The code below adds a simple bar in between numbers and it look like this "|"

I used ZNet GridView for getting 700 Points group header.


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.Pager)
TableCell sortCell = new TableCell();
sortCell.Text = "Page ";

Table tbl = (Table)e.Row.Cells[0].Controls[0];
foreach (TableCell mycells in tbl.Rows[0].Cells)

if (mycells.Controls[0] is Label)
Label lbl1 = new Label();
lbl1.Text = "|";

Label lbl2 = (Label)mycells.Controls[0];

else if (mycells.Controls[0] is LinkButton)
Label lbl = new Label();
lbl.Text = "|";

LinkButton lnk = (LinkButton)mycells.Controls[0];


tbl.Rows[0].Cells.AddAt(0, sortCell);


No comments:

Post a Comment