Articles → .NET → Accessing The Pager Row Using Toppagerrow And Bottompagerrow Property
Accessing The Pager Row Using Toppagerrow And Bottompagerrow Property
Prerequisite
 
- Binding the data to gridview
 - Paging in gridview
 
Binding Data With Grid
 
- Create an XML file.
 - Declare a data grid.
 - Apply the PageSettings tag in the data grid.
 - Bind data grid with XML file.
 
	<?xml version="1.0" encoding="utf-8" ?><root><book>book1</book><book>book2</book><book>book3</book><book>book4</book><book>book5</book><book>book6</book></root>
<asp:GridView ID="gvTest" runat="server" AllowPaging="true" PageSize="2" 
   onpageindexchanging="gvTest_PageIndexChanging" 
   onrowdatabound="gvTest_RowDataBound"><PagerSettings Position="TopAndBottom" /></asp:GridView>
protected void Page_Load(object sender,EventArgs e) {
	if (!IsPostBack) {
		BindGrid();
	}
}
private void BindGrid() {
	DataSet ds = new DataSet();
	ds.ReadXml(Server.MapPath("Pagerrow.xml"));
	gvTest.DataSource = ds.Tables[0];
	gvTest.DataBind();
}
protected void gvTest_PageIndexChanging(object sender, GridViewPageEventArgs e) {
	gvTest.PageIndex = e.NewPageIndex;
	BindGrid();
}
Output
 
Click to Enlarge
gvTest.TopPagerRow.BackColor = Color.Red;
gvTest.BottomPagerRow.BackColor = Color.Aqua;
Output
 
Click to Enlarge
| Posted By  -   | Karan Gupta | 
|   | 
| Posted On  -   | Thursday, December 8, 2011 | 
|   | 
| Updated On  -   | Monday, March 9, 2020 |