找了一下,只找到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 &nb