asp.net分页控页(vb.net)源码

找了一下,只找到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
    _
    
    
Public   Enum  PagerStyle

        Character
        NextPrev
        NumericPages
    
End Enum
  ' PagerStyle
    _
 
    
Public   Class  VirtualRecordCount
        
        
Public  RecordCount  As   Integer
        
Public  PageCount  As   Integer
        
' 最后一页的记录数
         Public  RecordsInLastPage  As   Integer
    
End Class
  ' VirtualRecordCount
    _
   
    
Public   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

        
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 ()
            
' _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( ByVal  sender  As   Object ByVal  e  As  PageChangedEventArgs)
        
Public   Event  PageIndexChanged  As  PageChangedEventHandler

        
Protected   Overridable   Sub  OnPageIndexChanged( ByVal  e  As  PageChangedEventArgs)
            
' 出错
             ' If Not (PageIndexChanged Is Nothing) Then
             RaiseEvent  PageIndexChanged( Me , e)
            
' End If
         End Sub
 
        
'  属性 导航条样式

        
Public   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()  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()  As  DataSet
            
Get
                
Return  (ViewState( " DataRecordset " ))
            
End   Get
            
Set ( ByVal  value  As  DataSet)
                ViewState(
" DataRecordset " =  value
            
End   Set
        
End Property


        
        
'  属性 每页记录数

        
Public   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()  As   Integer
            
Get
                
Return  Convert.ToInt32(ViewState( " CurrentPageIndex " ))
            
End   Get
            
Set ( ByVal  value  As   Integer )
                ViewState(
" CurrentPageIndex " =  value
            
End   Set
        
End Property
  ' <Description("取得设置数据库连接字符串")>  _
       
        
'  属性 连接字符串

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值