Articles → .NET → Accessing the pager row using TopPagerRow and BottomPagerRow property

Accessing the pager row using

TopPagerRow and BottomPagerRow property




Introduction





Prerequisite









Binding data with grid
















<?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


Picture showing top page row and bottom page row in data grid

Click to Enlarge



gvTest.TopPagerRow.BackColor = Color.Red;

gvTest.BottomPagerRow.BackColor = Color.Aqua;



Output


Picture showing the output of top page row and bottom page row in data grid

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, December 08, 2011
 
Updated On  -  Monday, March 09, 2020

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250