找了一下,只找到C#的,就改成vb.net的了 结合sql分页存储过程。 Imports System Imports System.IO Imports System.Drawing Imports System.Data Imports System.Data.SqlClient Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.ComponentModel Imports System.Configuration Namespace EasyPager Namespace EasyPager _ Public Enum PagerStyle Enum PagerStyle Character NextPrev NumericPages End Enum ' PagerStyle _ Public Class VirtualRecordCount Class VirtualRecordCount Public RecordCount As Integer Public PageCount As Integer ' 最后一页的记录数 Public RecordsInLastPage As Integer End Class ' VirtualRecordCount _ Public Class PageChangedEventArgs Class PageChangedEventArgs Inherits EventArgs Public OldPageIndex As Integer Public NewPageIndex As Integer End Class ' PageChangedEventArgs < DefaultProperty( " SelectCommand " ), DefaultEvent( " PageIndexChanged " ), ToolboxData( " <{0}:PagerProc runat=server /> " ) > _ Public Class PagerProc Class PagerProc Inherits WebControl Implements INamingContainer ' ToDo: Add Implements Clauses for implementation methods of these interface(s) ' 私有成员 ' 数据源 ' Private _dataSource As PagedDataSource ' '数据容器 ' Private _controlToPaginate As Control ' Private ReadOnly Property CacheKeyName() As String ' Get ' Return Page.Request.FilePath + "_" + UniqueID + "_Data" ' End Get ' End Property ' 导航条页面信息显示 Private CurrentPageText As String = " 当前第<font color={0}>{1}</font>页 共分<font color={0}>{2}</font>页 总计<font color={0}>{3}</font>条 每页<font color={0}>{4}</font>条 " ' 导航条无记录显示 Private NoPageSelectedText As String = " 没有记录! " ' 格式化sql查询语句 Private QueryPageCommandText As String = " SELECT * FROM " + " (SELECT TOP {0} * FROM " + " (SELECT TOP {1} * FROM ({2}) AS t0 ORDER BY {3} {4}) AS t1 " + " ORDER BY {3} {5}) AS t2 " + " ORDER BY {3} {4} " ' 格式化sql记录统计语句 Private QueryCountCommandText As String = " SELECT COUNT(*) FROM ({0}) AS t0 " ' 构造器 Public Sub New() Sub New () ' _dataSource = Nothing ' _controlToPaginate = Nothing Font.Name = " verdana " Font.Size = FontUnit.Point( 9 ) BackColor = Color.Gainsboro ForeColor = Color.Black IndexColor = Color.Black BorderStyle = BorderStyle.Outset BorderWidth = Unit.Parse( " 1px " ) PagerStyle = PagerStyle.Character CurrentPageIndex = 0 SelectTable = "" ConnectionString = "" PageSize = 15 TotalPages = - 1 End Sub ' New ' / <summary> ' / 事件 页面索引改变 ' / 当跳转到新页面时发生 ' / </summary> Delegate Sub PageChangedEventHandler() Sub PageChangedEventHandler( ByVal sender As Object , ByVal e As PageChangedEventArgs) Public Event PageIndexChanged As PageChangedEventHandler Protected Overridable Sub OnPageIndexChanged() Sub OnPageIndexChanged( ByVal e As PageChangedEventArgs) ' 出错 ' If Not (PageIndexChanged Is Nothing) Then RaiseEvent PageIndexChanged( Me , e) ' End If End Sub ' 属性 导航条样式 Public Property PagerStyle() Property PagerStyle() As PagerStyle Get Return CType (ViewState( " PagerStyle " ), PagerStyle) End Get Set ( ByVal value As PagerStyle) ViewState( " PagerStyle " ) = value End Set End Property ' <Description("指定索引值颜色")> _ ' *********************************************************************** ' 属性 索引值颜色 Public Property IndexColor() Property IndexColor() As Color Get Return CType (ViewState( " IndexColor " ), Color) End Get Set ( ByVal value As Color) ViewState( " IndexColor " ) = value End Set End Property ' <Description("取得设置数据容器的名字")> _ ' 属性 数据容器 ' Public Property ControlToPaginate() As String ' Get ' Return Convert.ToString(ViewState("ControlToPaginate")) ' End Get ' Set(ByVal value As String) ' ViewState("ControlToPaginate") = value ' End Set ' End Property ' 属性 数据集 Public Property DataRecordset() Property DataRecordset() As DataSet Get Return (ViewState( " DataRecordset " )) End Get Set ( ByVal value As DataSet) ViewState( " DataRecordset " ) = value End Set End Property ' 属性 每页记录数 Public Property PageSize() Property PageSize() As Integer Get Return Convert.ToInt32(ViewState( " PageSize " )) End Get Set ( ByVal value As Integer ) ViewState( " PageSize " ) = value End Set End Property ' <Description("取得设置当前页面索引")> _ ' 属性 当前页索引 Public Property CurrentPageIndex() Property CurrentPageIndex() As Integer Get Return Convert.ToInt32(ViewState( " CurrentPageIndex " )) End Get Set ( ByVal value As Integer ) ViewState( " CurrentPageIndex " ) = value End Set End Property ' <Description("取得设置数据库连接字符串")> _ ' 属性 连接字符串 Public Property ConnectionString() Property ConnectionString() As String Get Return Convert.ToString(ViewState( " ConnectionString " )) End Get Set ( ByVal value As String ) ViewState( " ConnectionString " ) = value End Set End Property ' <Description("取得设置数据库查询语句")> _ ' *********************************************************************** ' 属性 查询表 Public Property SelectTable() Property SelectTable() As String Get Return Convert.ToString(ViewState( " SelectTable " )) End Get Set ( ByVal value As String ) ViewState( " SelectTable " ) = value End Set End Property ' 属性 查询字段 Public Property SelectFields() Property SelectFields() As String Get Return Convert.ToString(ViewState( " SelectFields " )) End Get Set ( ByVal value As String ) ViewState( " SelectFields " ) = value End Set End Property ' 属性 条件字段 Public Property SelectWhere() Property SelectWhere() As String Get Return Convert.ToString(ViewState( " SelectWhere " )) End Get Set ( ByVal value As String ) ViewState( " SelectWhere " ) = value End Set End Property ' 属性 分组字段 Public Property SelectGroup() Property SelectGroup() As String Get Return Convert.ToString(ViewState( " SelectGroup " )) End Get Set ( ByVal value As String ) ViewState( " SelectGroup " ) = value End Set End Property ' 属性 排序字段 Public Property SortField() Property SortField() As String Get Return Convert.ToString(ViewState( " SortKeyField " )) End Get Set ( ByVal value As String ) ViewState( " SortKeyField " ) = value End Set End Property ' 属性 总页数 ' 取得显示页面的总数 Public ReadOnly Property PageCount() Property PageCount() As Integer Get Return TotalPages End Get End Property ' 属性 总页数 ' 取得设置显示页面的总数 Protected Property TotalPages() Property TotalPages() As Integer Get Return Convert.ToInt32(ViewState( " TotalPages " )) End Get Set ( ByVal value As Integer ) ViewState( " TotalPages " ) = value End Set End Property ' 属性 总记录数 ' 取得设置总记录数 Protected Property TotalRecords() Property TotalRecords() As Integer Get Return Convert.ToInt32(ViewState( " TotalRecords " )) End Get Set ( ByVal value As Integer ) ViewState( " TotalRecords " ) = value End Set End Property ' <Description("取得设置排序模式")> _ ' 方法 重载数据绑定 ' / <summary> ' / 取得,填充数据 ' / </summary> Public Overrides Sub DataBind() Sub DataBind() ' 触发数据绑定事件 MyBase .DataBind() ' 控件必须在数据绑定后重新创建 ChildControlsCreated = False ' 确定数据容器存在并且为列表控件(list control) ' If ControlToPaginate = "" Then ' Return ' End If ' _controlToPaginate = Page.FindControl(ControlToPaginate) ' If _controlToPaginate Is Nothing Then ' Return ' End If ' If Not (TypeOf _controlToPaginate Is BaseDataList Or TypeOf _controlToPaginate Is ListControl) Then ' Return ' End If ' 确定数据库连接字符串有效且查询命令已指定 If ConnectionString = "" Or SelectTable = "" Then Return End If ' 取得数据 FetchPageData() Return ' Bind data to the buddy control ' 绑定数据到数据容器 ' Dim baseDataListControl As BaseDataList = Nothing ' Dim listControl As ListControl = Nothing ' If TypeOf _controlToPaginate Is BaseDataList Then ' baseDataListControl = CType(_controlToPaginate, BaseDataList) ' baseDataListControl.DataSource = _dataSource ' baseDataListControl.DataBind() ' Return ' End If ' If TypeOf _controlToPaginate Is ListControl Then ' listControl = CType(_controlToPaginate, ListControl) ' listControl.Items.Clear() ' listControl.DataSource = _dataSource ' listControl.DataBind() ' Return ' End If End Sub ' DataBind ' 方法 重载 传递数据 ' 把数据内容传递到客户端 Protected Overrides Sub Render() Sub Render( ByVal output As HtmlTextWriter) ' If in design-mode ensure that child controls have been created. ' Child controls are not created at this time in design-mode because ' there's no pre-render stage. Do so for composite controls like this ' 出错 ' If Not (Site Is Nothing) And Site.DesignMode Then CreateChildControls() ' End If MyBase .Render(output) End Sub ' Render ' *********************************************************************** ' 方法 重载 创建子控件 ' Outputs the HTML markup for the control Protected Overrides Sub CreateChildControls() Sub CreateChildControls() Controls.Clear() ClearChildViewState() BuildControlHierarchy() End Sub ' CreateChildControls ' 方法 创建导航条 Private Sub BuildControlHierarchy() Sub BuildControlHierarchy() ' 导航条表格,1行2列 Dim t As New Table() t.Font.Name = Font.Name t.Font.Size = Font.Size t.BorderStyle = BorderStyle t.BorderWidth = BorderWidth t.BorderColor = BorderColor t.Width = Width t.Height = Height t.BackColor = BackColor t.ForeColor = ForeColor ' 表格行 Dim row As New TableRow() t.Rows.Add(row) ' 页面索引单元格 Dim cellPageDesc As New TableCell() cellPageDesc.HorizontalAlign = HorizontalAlign.Right BuildCurrentPage(cellPageDesc) row.Cells.Add(cellPageDesc) ' 导航按钮单元格 Dim cellNavBar As New TableCell() Select Case PagerStyle ' 字符导航条 Case PagerStyle.Character BuildCharacterUI(cellNavBar) Case PagerStyle.NextPrev BuildNextPrevUI(cellNavBar) Case PagerStyle.NumericPages BuildNumericPagesUI(cellNavBar) Case Else End Select row.Cells.Add(cellNavBar) Dim cellTip As New TableCell() cellTip.Text = " 跳转到 " row.Cells.Add(cellTip) ' 跳转到指定页输入框和按钮 Dim cellGotoPage As New TableCell() BuildGotoPage(cellGotoPage) row.Cells.Add(cellGotoPage) ' 把表格加入到控件树 Controls.Add(t) End Sub ' / 建立字符导航栏 ' / </summary> ' / <param name="cell"></param> Private Sub BuildCharacterUI() Sub BuildCharacterUI( ByVal cell As TableCell) Dim isValidPage As Boolean = CurrentPageIndex >= 0 And CurrentPageIndex <= TotalPages - 1 Dim canMoveBack As Boolean = CurrentPageIndex > 0 Dim canMoveForward As Boolean = CurrentPageIndex < TotalPages - 1 ' 定义首页按钮式样 Dim first As New LinkButton() first.ID = " First " first.CausesValidation = False AddHandler first.Click, AddressOf first_Click first.ToolTip = " 首页 " first.Text = " 首页 " first.Enabled = isValidPage And canMoveBack cell.Controls.Add(first) ' 加空格 cell.Controls.Add( New LiteralControl( " " )) ' 定义前页按钮式样 Dim prev As New LinkButton() prev.ID = " Prev " prev.CausesValidation = False AddHandler prev.Click, AddressOf prev_Click prev.ToolTip = " 前页 " prev.Text = " 前页 " prev.Enabled = isValidPage And canMoveBack cell.Controls.Add(prev) ' 加空格 cell.Controls.Add( New LiteralControl( " " )) ' 定义后页按钮式样 Dim [ next ] As New LinkButton() [ next ].ID = " Next " [ next ].CausesValidation = False AddHandler [ next ].Click, AddressOf next_Click [ next ].ToolTip = " 后页 " [ next ].Text = " 后页 " [ next ].Enabled = isValidPage And canMoveForward cell.Controls.Add([ next ]) ' 加空格 cell.Controls.Add( New LiteralControl( " " )) ' 定义尾页按钮式样 Dim last As New LinkButton() last.ID = " Last " last.CausesValidation = False AddHandler last.Click, AddressOf last_Click last.ToolTip = " 尾页 " last.Text = " 尾页 " last.Enabled = isValidPage And canMoveForward cell.Controls.Add(last) End Sub ' BuildCharacterUI ' PRIVATE BuildNextPrevUI ' Generates the HTML markup for the Next/Prev navigation bar Private Sub BuildNextPrevUI() Sub BuildNextPrevUI( ByVal cell As TableCell) Dim isValidPage As Boolean = CurrentPageIndex >= 0 And CurrentPageIndex <= TotalPages - 1 Dim canMoveBack As Boolean = CurrentPageIndex > 0 Dim canMoveForward As Boolean = CurrentPageIndex < TotalPages - 1 ' Render the << button Dim first As New LinkButton() first.ID = " First " AddHandler first.Click, AddressOf first_Click first.Font.Name = " webdings " first.Font.Size = FontUnit.Medium first.ForeColor = ForeColor first.ToolTip = " 首页 " first.Text = " 7 " first.Enabled = isValidPage And canMoveBack cell.Controls.Add(first) ' Add a separator cell.Controls.Add( New LiteralControl( " " )) ' Render the < button Dim prev As New LinkButton() prev.ID = " Prev " AddHandler prev.Click, AddressOf prev_Click prev.Font.Name = " webdings " prev.Font.Size = FontUnit.Medium prev.ForeColor = ForeColor prev.ToolTip = " 上一页 " prev.Text = " 3 " prev.Enabled = isValidPage And canMoveBack cell.Controls.Add(prev) ' Add a separator cell.Controls.Add( New LiteralControl( " " )) ' Render the > button Dim [ next ] As New LinkButton() [ next ].ID = " Next " AddHandler [ next ].Click, AddressOf next_Click [ next ].Font.Name = " webdings " [ next ].Font.Size = FontUnit.Medium [ next ].ForeColor = ForeColor [ next ].ToolTip = " 下一页 " [ next ].Text = " 4 " [ next ].Enabled = isValidPage And canMoveForward cell.Controls.Add([ next ]) ' Add a separator cell.Controls.Add( New LiteralControl( " " )) ' Render the >> button Dim last As New LinkButton() last.ID = " Last " AddHandler last.Click, AddressOf last_Click last.Font.Name = " webdings " last.Font.Size = FontUnit.Medium last.ForeColor = ForeColor last.ToolTip = " 尾页 " last.Text = " 8 " last.Enabled = isValidPage And canMoveForward cell.Controls.Add(last) End Sub ' BuildNextPrevUI ' PRIVATE BuildNumericPagesUI ' Generates the HTML markup for the Numeric Pages button bar Private Sub BuildNumericPagesUI() Sub BuildNumericPagesUI( ByVal cell As TableCell) ' Render a drop-down list Dim pageList As New DropDownList() pageList.ID = " PageList " pageList.AutoPostBack = True AddHandler pageList.SelectedIndexChanged, AddressOf PageList_Click pageList.Font.Name = Font.Name pageList.Font.Size = Font.Size pageList.ForeColor = ForeColor ' Embellish the list when there are no pages to list If TotalPages <= 0 Or CurrentPageIndex = - 1 Then pageList.Items.Add( " No pages " ) pageList.Enabled = False pageList.SelectedIndex = 0 ' Populate the list Else Dim i As Integer For i = 1 To TotalPages Dim item As New ListItem(i.ToString(), (i - 1 ).ToString()) pageList.Items.Add(item) Next i pageList.SelectedIndex = CurrentPageIndex End If cell.Controls.Add(pageList) End Sub ' BuildNumericPagesUI ' 方法 建立跳转到指定页面 Private Sub BuildGotoPage() Sub BuildGotoPage( ByVal cell As TableCell) ' bool isValidPage = (CurrentPageIndex >=0 && CurrentPageIndex <= TotalPages-1); ' 跳转到页面索引输入框 Dim txbPage As New TextBox() txbPage.ID = " txbPage " txbPage.Width = 50 txbPage.MaxLength = 5 cell.Controls.Add(txbPage) ' 加空格 cell.Controls.Add( New LiteralControl( " " )) ' 跳转到按钮 Dim btnGo As New Button() btnGo.ID = " btnGo " btnGo.Text = " 确定 " btnGo.BorderStyle = BorderStyle.Ridge btnGo.BorderWidth = 1 btnGo.CausesValidation = False AddHandler btnGo.Click, AddressOf btnGo_Click ' btnGo.Enabled = isValidPage; cell.Controls.Add(btnGo) End Sub ' BuildGotoPage ' 方法 当前页索引 ' 从0开始 Private Sub BuildCurrentPage() Sub BuildCurrentPage( ByVal cell As TableCell) Dim lblIndex As New Label() Dim temp As String = "" ' Use a standard template: Page X of Y If CurrentPageIndex < 0 Or CurrentPageIndex >= TotalPages Then temp = NoPageSelectedText Else temp = [ String ].Format(CurrentPageText, IndexColor.Name, CurrentPageIndex + 1 , TotalPages, TotalRecords, PageSize) End If lblIndex.Text = temp cell.Controls.Add(lblIndex) End Sub ' BuildCurrentPage ' / <summary> ' / 方法 验证索引是否有效 ' / 确定当前页面索引范围:[0,TotalPages) or -1 ' / </summary> Private Sub ValidatePageIndex() Sub ValidatePageIndex() ' 如果当前页记录删除,跳到前一页 If CurrentPageIndex = TotalPages Then CurrentPageIndex -= 1 End If If Not (CurrentPageIndex >= 0 And CurrentPageIndex < TotalPages) Then CurrentPageIndex = - 1 End If Return End Sub ' ValidatePageIndex ' / <summary> ' / 方法 获取当前页面数据 ' / </summary> Private Sub FetchPageData() Sub FetchPageData() ' Private ' 必须获得一个有效的页面索引 ' 还需要虚拟页面记录统计来验证页面索引 ' AdjustSelectCommand(False) Dim countInfo As VirtualRecordCount = CalculateVirtualRecordCount() TotalPages = countInfo.PageCount TotalRecords = countInfo.RecordCount ' 验证页面索引值的有效性(当前页面索引必须有效或为-1) ValidatePageIndex() If CurrentPageIndex = - 1 Then CurrentPageIndex = 0 End If ' return; ' 准备,运行数据库查询 Dim cmd As New SqlCommand ' = PrepareCommand(countInfo) Dim conn As New SqlConnection(ConnectionString) With cmd .CommandType = CommandType.StoredProcedure .CommandText = " Paging_RowCount " .Parameters.Add( " @PageNumber " , SqlDbType.Int) .Parameters( " @PageNumber " ).Value = CurrentPageIndex + 1 .Parameters.Add( " @PageSize " , SqlDbType.Int) .Parameters( " @PageSize " ).Value = PageSize .Parameters.Add( " @Tables " , SqlDbType.Text) .Parameters( " @Tables " ).Value = SelectTable .Parameters.Add( " @Sort " , SqlDbType.Text) .Parameters( " @Sort " ).Value = SortField .Parameters.Add( " @Fields " , SqlDbType.Text) .Parameters( " @Fields " ).Value = SelectFields .Parameters.Add( " @Filter " , SqlDbType.Text) .Parameters( " @Filter " ).Value = SelectWhere .Parameters.Add( " @Group " , SqlDbType.Text) .Parameters( " @Group " ).Value = SelectGroup .Connection = conn End With If cmd Is Nothing Then Return End If Dim adapter As New SqlDataAdapter(cmd) ' Dim data As New DataTable() ' adapter.Fill(data) DataRecordset = New DataSet() adapter.Fill(DataRecordset) ' 配置翻页数据源组件 ' If _dataSource Is Nothing Then ' _dataSource = New PagedDataSource() ' End If ' _dataSource.AllowCustomPaging = True ' _dataSource.AllowPaging = True ' _dataSource.CurrentPageIndex = 0 ' _dataSource.PageSize = PageSize ' _dataSource.VirtualCount = countInfo.RecordCount ' _dataSource.DataSource = data.DefaultView End Sub ' FetchPageData ' / 方法 计算记录统计 ' / 计算指定查询的记录及页面数 ' / </summary> ' / <returns>记录统计</returns> Private Function CalculateVirtualRecordCount() Function CalculateVirtualRecordCount() As VirtualRecordCount Dim count As New VirtualRecordCount() ' 计算记录数 count.RecordCount = GetQueryVirtualCount() count.RecordsInLastPage = PageSize ' 计算交互记录信息 Dim lastPage As Integer = count.RecordCount PageSize Dim remainder As Integer = count.RecordCount Mod PageSize If remainder > 0 Then lastPage += 1 End If count.PageCount = lastPage ' 计算最后一页的记录数 If remainder > 0 Then count.RecordsInLastPage = remainder End If Return count End Function Private Function SelectCommand() Function SelectCommand() As String Dim Sstr As String If SelectWhere <> "" Then Sstr = " select " & SelectFields & " from " & SelectTable & " where " & SelectWhere Else Sstr = " select " & SelectFields & " from " & SelectTable & "" End If Return Sstr End Function ' / <summary> ' / 方法 格式化查询语句 ' / </summary> ' / <param name="countInfo">记录统计</param> ' / <returns>command对象</returns> ' Private Function PrepareCommand(ByVal countInfo As VirtualRecordCount) As SqlCommand ' ' 如排序字段没有定义 ' If SortField = "" Then ' ' Get metadata for all columns and choose either the primary key ' ' or the ' ' 取得所有列的数据,并取任意一列数据为主键 ' Dim [text] As String = "SET FMTONLY ON;" + SelectCommand + ";SET FMTONLY OFF;" ' Dim adapter As New SqlDataAdapter([text], ConnectionString) ' Dim t As New DataTable() ' adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey ' adapter.Fill(t) ' Dim col As DataColumn = Nothing ' If t.PrimaryKey.Length > 0 Then ' col = t.PrimaryKey(0) ' Else ' col = t.Columns(0) ' End If ' SortField = col.ColumnName ' End If ' ' 确定要得到多少条数据 ' ' 最后一页的数据不会多于前页 ' Dim recsToRetrieve As Integer = PageSize ' If CurrentPageIndex = countInfo.PageCount - 1 Then ' recsToRetrieve = countInfo.RecordsInLastPage ' End If ' Dim cmdText As String = [String].Format(QueryPageCommandText, recsToRetrieve, PageSize * (CurrentPageIndex + 1), SelectCommand, SortField, SortMode, AlterSortMode(SortMode)) ' ' {0} --> page size ' ' {1} --> size * index ' ' {2} --> base query ' ' {3} --> key field in the query ' ' {4} --> 排序模式 ' Dim conn As New SqlConnection(ConnectionString) ' Dim cmd As New SqlCommand(cmdText, conn) ' Return cmd ' End Function 'PrepareCommand ' / 方法 取得总记录条数 ' / </summary> ' / <returns>总记录条数</returns> Private Function GetQueryVirtualCount() Function GetQueryVirtualCount() As Integer Dim cmdText As String = [ String ].Format(QueryCountCommandText, SelectCommand) Dim conn As New SqlConnection(ConnectionString) Dim cmd As New SqlCommand(cmdText, conn) cmd.Connection.Open() Dim recCount As Integer = CInt (cmd.ExecuteScalar()) cmd.Connection.Close() Return recCount End Function ' GetQueryVirtualCount ' / 方法 跳转到指定页面 ' / </summary> ' / <param name="pageIndex">页面索引</param> Private Sub GoToPage() Sub GoToPage( ByVal pageIndex As Integer ) ' 准备事件数据 Dim e As New PageChangedEventArgs() e.OldPageIndex = CurrentPageIndex e.NewPageIndex = pageIndex ' 更新当前页面索引 CurrentPageIndex = pageIndex ' 触发页面改变事件 OnPageIndexChanged(e) ' 绑定新的数据 DataBind() End Sub ' GoToPage ' / 方法 跳转到第一页 ' / </summary> ' / <param name="sender"></param> ' / <param name="e"></param> Private Sub first_Click() Sub first_Click( ByVal sender As Object , ByVal e As EventArgs) GoToPage( 0 ) End Sub ' first_Click ' / 方法 跳转到前一页 ' / </summary> ' / <param name="sender"></param> ' / <param name="e"></param> Private Sub prev_Click() Sub prev_Click( ByVal sender As Object , ByVal e As EventArgs) GoToPage((CurrentPageIndex - 1 )) End Sub ' prev_Click ' / 方法 跳转到后一页 ' / </summary> ' / <param name="sender"></param> ' / <param name="e"></param> Private Sub next_Click() Sub next_Click( ByVal sender As Object , ByVal e As EventArgs) GoToPage((CurrentPageIndex + 1 )) End Sub ' next_Click ' / 方法 跳转到最后一页 ' / </summary> ' / <param name="sender"></param> ' / <param name="e"></param> Private Sub last_Click() Sub last_Click( ByVal sender As Object , ByVal e As EventArgs) GoToPage((TotalPages - 1 )) End Sub ' last_Click ' / 方法 页面索引选择列表点击 ' / 通过下拉框选择页面索引 ' / </summary> ' / <param name="sender"></param> ' / <param name="e"></param> Private Sub PageList_Click() Sub PageList_Click( ByVal sender As Object , ByVal e As EventArgs) Dim pageList As DropDownList = CType (sender, DropDownList) Dim pageIndex As Integer = Convert.ToInt32(pageList.SelectedItem.Value) GoToPage(pageIndex) End Sub ' PageList_Click ' / <summary> ' / 方法 跳转到指定页面按钮点击 ' / </summary> ' / <param name="sender"></param> ' / <param name="e"></param> Private Sub btnGo_Click() Sub btnGo_Click( ByVal sender As Object , ByVal e As EventArgs) ' bool isValidPage = (CurrentPageIndex >=0 && CurrentPageIndex < TotalPages); Dim txbpage As TextBox = CType (FindControl( " txbPage " ), TextBox) If txbpage.Text.Length > 0 And IsNumeric (txbpage.Text) Then Dim page As Integer = Convert.ToInt32(txbpage.Text.Trim()) Dim isValidPage As Boolean = page - 1 >= 0 And page - 1 < TotalPages If isValidPage = True Then GoToPage((page - 1 )) End If End If End Sub ' btnGo_Click End Class ' ' *********************************************************************** End Namespace '