Articles → .NET → Accessing The Pager Row Using Toppagerrow And Bottompagerrow Property

Accessing The Pager Row Using Toppagerrow And Bottompagerrow Property






Prerequisite




  1. Binding the data to gridview
  2. Paging in gridview

Binding Data With Grid




  1. Create an XML file.
  2. Declare a data grid.
  3. Apply the PageSettings tag in the data grid.
  4. 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


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 8, 2011
 
Updated On  -  Monday, March 9, 2020

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250