Seeing a lot of custom paging in 9CBS, referring to a lot, but old feels that the functions written by others are not very complete, and they also wrote one, mainly referring to the "Mencius E chapter" Paging example .
This is VB.NET language here.
DataGridPaging.aspx
<% @ Page language = "vb" autoeventwireup = "false" codebehind = "DataGridPaging.aspx.vb" inherits = "Webwuye.DataGridPaging"%> Refer to my reply below, here is not the code.
DataGridPaging.aspx.vb
Imports system.data.sqlclientimports system.dataimports system.Web.ui
Public class datagridpaging inherits system.web.ui.page
Protected WithEvents btnFirst As System.Web.UI.WebControls.LinkButton Protected WithEvents btnPrev As System.Web.UI.WebControls.LinkButton Protected WithEvents btnNext As System.Web.UI.WebControls.LinkButton Protected WithEvents btnLast As System.Web.UI.WebControls .LinkButton Protected WithEvents lblCurrentIndex As System.Web.UI.WebControls.Label Protected WithEvents lblPageCount As System.Web.UI.WebControls.Label Protected WithEvents lblRegisterCount As System.Web.UI.WebControls.Label Protected WithEvents DataGrid As System.Web.UI .WebControls.DataGrid protected withevents datagrid1 as system.Web.ui.WebControls.DataGrid
#Region "Web Form Designer Generated Code"
'THIS CALL IS Required by The Web Form Designer.
End Sub
Private Sub Page_Init (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer' Do not modify it using the code editor InitializeComponent () End Sub.
#End region
Dim cnn As New SqlConnection ( "Password =; User ID = sa; Initial Catalog = northwind; Data Source = localhost; Connect Timeout = 30") Dim adp As New SqlDataAdapter Dim cmd As New SqlCommand Dim ds As New DataSet 'Dim intStartIndex As Long
'Define global static variables, record the total number of records before the selected page Private Shared Preceding As Long Private Shared Gridpagesize As INT16
Private Sub Page_Load (Byvale AS System.Object, Byval E AS System.Eventargs) Handles MyBase.Load
btnfirst.text = "The top page" btnnext.text = "Previous page" btnnext.text = "BTNLast.Text =" Last page "
If Not IsPostback THEN TRY DIM CMD AS New SqlCommand ("Select Count (*) from Products", CNN) CNN.Open () Set the number of actual items in the DataGrid control when using custom paging. 'Dim i As Int16' i = cmd.ExecuteScalar () 'MyDataGrid.VirtualItemCount = (i / MyDataGrid.PageSize) DataGrid1.VirtualItemCount = cmd.ExecuteScalar () Catch ex As Exception Response.Write ( "