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 EasyPagerNamespace EasyPager _ PublicEnum PagerStyleEnum PagerStyle Character NextPrev NumericPages End Enum'PagerStyle _ PublicClass VirtualRecordCountClass VirtualRecordCount Public RecordCount AsInteger Public PageCount AsInteger '最后一页的记录数 Public RecordsInLastPage AsInteger End Class'VirtualRecordCount _ PublicClass PageChangedEventArgsClass PageChangedEventArgs Inherits EventArgs Public OldPageIndex AsInteger Public NewPageIndex AsInteger End Class'PageChangedEventArgs <DefaultProperty("SelectCommand"), DefaultEvent("PageIndexChanged"), ToolboxData("<{0}:PagerProc runat=server />")> _ PublicClass PagerProcClass 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 AsString="当前第<font color={0}>{1}</font>页 共分<font color={0}>{2}</font>页 总计<font color={0}>{3}</font>条 每页<font color={0}>{4}</font>条" '导航条无记录显示 Private NoPageSelectedText AsString="没有记录!" '格式化sql查询语句 Private QueryPageCommandText AsString="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 AsString="SELECT COUNT(*) FROM ({0}) AS t0" ' 构造器 PublicSub New()SubNew() '_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> DelegateSub PageChangedEventHandler()Sub PageChangedEventHandler(ByVal sender AsObject, ByVal e As PageChangedEventArgs) PublicEvent PageIndexChanged As PageChangedEventHandler ProtectedOverridableSub OnPageIndexChanged()Sub OnPageIndexChanged(ByVal e As PageChangedEventArgs) '出错 'If Not (PageIndexChanged Is Nothing) Then RaiseEvent PageIndexChanged(Me, e) 'End If End Sub ' 属性 导航条样式 PublicProperty PagerStyle()Property PagerStyle() As PagerStyle Get ReturnCType(ViewState("PagerStyle"), PagerStyle) EndGet Set(ByVal value As PagerStyle) ViewState("PagerStyle") = value EndSet End Property'<Description("指定索引值颜色")> _ ' *********************************************************************** ' 属性 索引值颜色 PublicProperty IndexColor()Property IndexColor() As Color Get ReturnCType(ViewState("IndexColor"), Color) EndGet Set(ByVal value As Color) ViewState("IndexColor") = value EndSet 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 ' 属性 数据集 PublicProperty DataRecordset()Property DataRecordset() As DataSet Get Return (ViewState("DataRecordset")) EndGet Set(ByVal value As DataSet) ViewState("DataRecordset") = value EndSet End Property ' 属性 每页记录数 PublicProperty PageSize()Property PageSize() AsInteger Get Return Convert.ToInt32(ViewState("PageSize")) EndGet Set(ByVal value AsInteger) ViewState("PageSize") = value EndSet End Property'<Description("取得设置当前页面索引")> _ ' 属性 当前页索引 PublicProperty CurrentPageIndex()Property CurrentPageIndex() AsInteger Get Return Convert.ToInt32(ViewState("CurrentPageIndex")) EndGet Set(ByVal value AsInteger) ViewState("CurrentPageIndex") = value EndSet End Property'<Description("取得设置数据库连接字符串")> _ ' 属性 连接字符串 P