Articles → ASP .NET GRIDVIEW → Gridview Paging In Asp.Net
Gridview Paging In Asp.Net
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" />
- AllowPaging – Permissible values are true or false. For paging, we set the value to True.
- PageSize – It means how many records will be visible on a single page.
- 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
Click to Enlarge