ASP.NET(vb.net) & GridView - AllowPaging/Pagination Example scripts how to Explains GridView control in asp.net , The GridView.AllowPaging gets or sets a value indicating whether the paging feature is enabled.
ShotDev Focus:
- ASP.NET(vb.net) & GridView - AllowPaging
Example
GridViewAllowPaging.aspx
<%@ Import Namespace="System.Data"%> <%@ Import Namespace="System.Data.OleDb"%> <%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) IF Not Page.IsPostBack() Then BindData() End IF End Sub Sub BindData() Dim objConn As New OleDbConnection Dim objCmd As New OleDbCommand Dim dtAdapter As New OleDbDataAdapter Dim ds As New DataSet Dim strConnString,strSQL As String strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& _ Server.MapPath("database/mydatabase.mdb")&";" strSQL = "SELECT * FROM customer" objConn.ConnectionString = strConnString With objCmd .Connection = objConn .CommandText = strSQL .CommandType = CommandType.Text End With dtAdapter.SelectCommand = objCmd dtAdapter.Fill(ds) '*** BindData to GridView ***' myGridView.DataSource = ds myGridView.DataBind() dtAdapter = Nothing objConn.Close() objConn = Nothing End Sub Sub ShowPageCommand(s As Object, e As GridViewPageEventArgs) myGridView.PageIndex = e.NewPageIndex BindData() End Sub </script> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form id="form1" runat="server" > <asp:GridView id="myGridView" PageSize="2" OnPageIndexChanging="ShowPageCommand" AllowPaging="True" runat="server"> <HeaderStyle BackColor="#cccccc"></HeaderStyle> <AlternatingRowStyle BackColor="Gainsboro"></AlternatingRowStyle> </asp:GridView> </form> </body> </html>
Create a asp.net file and save to path root-path/dotnet/
Run
http://localhost/dotnet/GridViewAllowPaging.aspx
Screenshot
3devotedness…
…