Articles → ASP .NET GRIDVIEW → Gridview Paging In Asp.Net

Gridview Paging In Asp.Net





Picture showing the database table with records
Click to Enlarge



<asp:GridView ID="gvTest" runat="server" DataSourceID="dsTest"></asp:GridView>
<asp:SqlDataSource ConnectionString="connection_string" ID="dsTest" SelectCommand="Select * from Member" runat="server" />




  1. AllowPaging – Permissible values are true or false. For paging, we set the value to True.
  2. PageSize – It means how many records will be visible on a single page.
  3. OnPageIndexChanging – This is an event that is invoked when the user clicks on any page number in pager control.


<asp:GridView ID="gvTest" runat="server" DataSourceID="dsTest" AllowPaging="true" PageSize="2" OnPageIndexChanging="gvTest_PageIndexChanging"></asp:GridView>
<asp:SqlDataSource ConnectionString="connection_string" ID="dsTest" SelectCommand="Select * from Member" runat="server" />




protected void gvTest_PageIndexChanging(object sender, GridViewPageEventArgs e) {
	gvTest.PageIndex = e.NewPageIndex;
}



Output


Picture showing the output of Gridview paging in asp.net
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, May 21, 2015

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250