控件的属性及事件定义
Private Shared ReadOnly EventibGotoPageClick As New Object()
Private Shared ReadOnly EventlbGotoPageClick As New Object()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Private Conn As SqlConnection
Private _StoredProcedureName As String
Private _ControlToDataBind As String
Private _GoToStyle As StyleGoTo = StyleGoTo.LinkButton
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Private intPageCount As Int32 = 0
Private intRecordCount As Int32 = 0
Private intPageSize As Int32
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Private _DefaultImageUrl As String
Private _HoverImageUrl As String
Private _PressedImageUrl As String
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Private _controlToPaginat As Control
Private labPageInfo As Label
Private labPageInfoText_01 As Label
Private labPageInfoText_02 As Label
Private labPageInfoText_03 As Label
Private labPageInfoText_04 As Label
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Private txtPageSize As TextBox
Private txtPageIndex As TextBox
Private ibGotoPage As ImageButton
Private lbGotoPage As LinkButton
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Private lbFirstPage As LinkButton
Private lbPrevPage As LinkButton
Private lbNextPage As LinkButton
Private lbLastPage As LinkButton
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
属性定义#Region "属性定义"
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
< _
Bindable(True), _
Category("PageInfo"), _
DefaultValue(""), _
Description("设置页的信息(例如:当前 100 条记录...).") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageInfoText()Property PageInfoText() As String
Get
EnsureChildControls()
Return labPageInfo.Text
End Get
Set(ByVal value As String)
EnsureChildControls()
labPageInfo.Text = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("PageInfo"), _
DefaultValue(""), _
Description("设置显示 每页 字符.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageInfoText_01()Property PageInfoText_01() As String
Get
EnsureChildControls()
Return labPageInfoText_01.Text
End Get
Set(ByVal value As String)
EnsureChildControls()
labPageInfoText_01.Text = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("PageInfo"), _
DefaultValue(""), _
Description("设置显示 条记录 字符.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageInfoText_02()Property PageInfoText_02() As String
Get
EnsureChildControls()
Return labPageInfoText_02.Text
End Get
Set(ByVal value As String)
EnsureChildControls()
labPageInfoText_02.Text = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("PageInfo"), _
DefaultValue(""), _
Description("设置显示 转到 字符.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageInfoText_03()Property PageInfoText_03() As String
Get
EnsureChildControls()
Return labPageInfoText_03.Text
End Get
Set(ByVal value As String)
EnsureChildControls()
labPageInfoText_03.Text = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("PageInfo"), _
DefaultValue(""), _
Description("设置显示 页 字符.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageInfoText_04()Property PageInfoText_04() As String
Get
EnsureChildControls()
Return labPageInfoText_04.Text
End Get
Set(ByVal value As String)
EnsureChildControls()
labPageInfoText_04.Text = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Style"), _
DefaultValue(""), _
Description("页大小 Textbox 边框的宽度.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property TextboxBorderWidth()Property TextboxBorderWidth() As Unit
Get
EnsureChildControls()
Return txtPageSize.BorderWidth
End Get
Set(ByVal value As Unit)
EnsureChildControls()
txtPageSize.BorderWidth = value
txtPageIndex.BorderWidth = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Style"), _
DefaultValue(""), _
Description("页大小 Textbox 边框的颜色.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property TextboxBorderColor()Property TextboxBorderColor() As System.Drawing.Color
Get
EnsureChildControls()
Return txtPageSize.BorderColor
End Get
Set(ByVal value As System.Drawing.Color)
EnsureChildControls()
txtPageSize.BorderColor = value
txtPageIndex.BorderColor = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Style"), _
DefaultValue(""), _
Description("页大小 Textbox 的SkinID.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property TextboxSkinID()Property TextboxSkinID() As String
Get
EnsureChildControls()
Return txtPageSize.SkinID
End Get
Set(ByVal value As String)
EnsureChildControls()
txtPageSize.SkinID = value
txtPageIndex.SkinID = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Style"), _
DefaultValue(""), _
Description("设置转到的的风格.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property GoToStyle()Property GoToStyle() As StyleGoTo
Get
EnsureChildControls()
Return Me._GoToStyle
End Get
Set(ByVal value As StyleGoTo)
EnsureChildControls()
Me._GoToStyle = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Style"), _
DefaultValue(""), _
Description("设置转到的按钮默认图片.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property DefaultImageUrl()Property DefaultImageUrl() As String
Get
EnsureChildControls()
Return ibGotoPage.ImageUrl
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
End Get
Set(ByVal value As String)
EnsureChildControls()
ibGotoPage.ImageUrl = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Style"), _
DefaultValue(""), _
Description("设置当鼠标指针在按钮上时显示的图片.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property HoverImageUrl()Property HoverImageUrl() As String
Get
EnsureChildControls()
Return Me._HoverImageUrl
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
End Get
Set(ByVal value As String)
EnsureChildControls()
Me._HoverImageUrl = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Style"), _
DefaultValue(""), _
Description("设置当鼠标按下时显示的图片.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PressedImageUrl()Property PressedImageUrl() As String
Get
EnsureChildControls()
Return Me._PressedImageUrl
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
End Get
Set(ByVal value As String)
EnsureChildControls()
Me._PressedImageUrl = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Size"), _
DefaultValue(""), _
Description("设置 PageSize 文本框宽度.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageSizeWidth()Property PageSizeWidth() As Unit
Get
EnsureChildControls()
Return txtPageSize.Width
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
End Get
Set(ByVal value As Unit)
EnsureChildControls()
txtPageSize.Width = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Size"), _
DefaultValue(""), _
Description("设置 PageIndex 文本框宽度.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageIndexWidth()Property PageIndexWidth() As Unit
Get
EnsureChildControls()
Return txtPageIndex.Width
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
End Get
Set(ByVal value As Unit)
EnsureChildControls()
txtPageIndex.Width = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Size"), _
DefaultValue(""), _
Description("设置 转到 按钮的宽度.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property ibGotoPageWidth()Property ibGotoPageWidth() As Unit
Get
EnsureChildControls()
Return ibGotoPage.Width
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
End Get
Set(ByVal value As Unit)
EnsureChildControls()
ibGotoPage.Width = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Size"), _
DefaultValue(""), _
Description("设置 转到 按钮的高度.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property ibGotoPageHeight()Property ibGotoPageHeight() As Unit
Get
EnsureChildControls()
Return ibGotoPage.Height
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
End Get
Set(ByVal value As Unit)
EnsureChildControls()
ibGotoPage.Height = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Text"), _
DefaultValue(""), _
Description("设置 转到 链接按钮的文字.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property lbGotoPageText()Property lbGotoPageText() As String
Get
EnsureChildControls()
Return lbGotoPage.Text
End Get
Set(ByVal value As String)
EnsureChildControls()
lbGotoPage.Text = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
Description("设置链接数据库的字符串.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property SQLConnection()Property SQLConnection() As String
Get
EnsureChildControls()
Return ViewState("SQLConnection")
End Get
Set(ByVal value As String)
EnsureChildControls()
ViewState("SQLConnection") = value
End Set
End Property
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
Description("设置表名.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property TableName()Property TableName() As String
Get
EnsureChildControls()
Return ViewState("TableName")
End Get
Set(ByVal value As String)
EnsureChildControls()
ViewState("TableName") = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
Description("设置分页数据的主键.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PrimaryKeyField()Property PrimaryKeyField() As String
Get
EnsureChildControls()
Return ViewState("PrimaryKeyField")
End Get
Set(ByVal value As String)
EnsureChildControls()
ViewState("PrimaryKeyField") = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
Description("设置返回的字段.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property Field()Property Field() As String
Get
EnsureChildControls()
Return ViewState("Field")
End Get
Set(ByVal value As String)
EnsureChildControls()
ViewState("Field") = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
Description("设置 WHERE 条件.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property Where()Property Where() As String
Get
EnsureChildControls()
Return ViewState("Where")
End Get
Set(ByVal value As String)
EnsureChildControls()
ViewState("Where") = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Browsable(True), _
Category("Database"), _
DefaultValue(""), _
Description("设置排序方式.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property OrderBy()Property OrderBy() As String
Get
EnsureChildControls()
Return ViewState("OrderBy")
End Get
Set(ByVal value As String)
EnsureChildControls()
ViewState("OrderBy") = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
Description("设置分组方式.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property GroupBy()Property GroupBy() As String
Get
EnsureChildControls()
Return ViewState("GroupBy")
End Get
Set(ByVal value As String)
EnsureChildControls()
ViewState("GroupBy") = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
TypeConverter(GetType(ControlToDataBindConverter)), _
Description("设置要分页的控件.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property ControlToPaginate()Property ControlToPaginate() As String
Get
EnsureChildControls()
Return ViewState("ControlToPaginate")
End Get
Set(ByVal value As String)
EnsureChildControls()
ViewState("ControlToPaginate") = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(1), _
Description("设置当前页.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property CurrentPageIndex()Property CurrentPageIndex() As Int32
Get
EnsureChildControls()
Return ViewState("CurrentPageIndex")
End Get
Set(ByVal value As Int32)
EnsureChildControls()
ViewState("CurrentPageIndex") = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
Description("每页显示数据的大小.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageSize()Property PageSize() As Int32
Get
EnsureChildControls()
If Not IsNumeric(txtPageSize.Text) Then
txtPageSize.Text = 10
Else
If CInt(txtPageSize.Text) < 1 Then
txtPageSize.Text = 10
End If
End If
Return CInt(txtPageSize.Text)
End Get
Set(ByVal value As Int32)
EnsureChildControls()
txtPageSize.Text = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(True), _
Category("Database"), _
DefaultValue(""), _
Description("将要转到的页数.") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property PageIndex()Property PageIndex() As String
Get
EnsureChildControls()
Return txtPageIndex.Text
End Get
Set(ByVal value As String)
EnsureChildControls()
txtPageIndex.Text = value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(False), _
Category("Database"), _
DefaultValue(""), _
TypeConverter(GetType(StoredProcedureNameConverter)), _
Description("选择存储过程。") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Property StoredProcedureName()Property StoredProcedureName() As String
Get
Return _StoredProcedureName
End Get
Set(ByVal Value As String)
_StoredProcedureName = Value
End Set
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
< _
Bindable(False), _
Category("About"), _
DefaultValue(""), _
Description("作者:江建 QQ:33512603" & vbCrLf & "编程浪子:http://vbcc.126.com") _
> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public ReadOnly Property About()Property About() As String
Get
Return "作者:江建 QQ:33512603" & vbCrLf & "编程浪子:http://vbcc.126.com"
End Get
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<Browsable(False)> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public ReadOnly Property PageCount()Property PageCount() As Int32
Get
EnsureChildControls()
Return ViewState("PageCount")
End Get
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<Browsable(False)> _
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public ReadOnly Property RecordCount()Property RecordCount() As Int32
Get
EnsureChildControls()
Return ViewState("RecordCount")
End Get
End Property
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#End Region
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
事件定义#Region "事件定义"
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Private Sub ibGotoPage_Click()Sub ibGotoPage_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
If Not IsNumeric(PageIndex) Then
PageIndex = CurrentPageIndex
End If
If PageIndex < 1 Then
PageIndex = 1
ElseIf PageIndex > PageCount Then
PageIndex = PageCount
End If
CurrentPageIndex = PageIndex
Call DataBind()
End Sub
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Private Sub lbGotoPage_Click()Sub lbGotoPage_Click(ByVal source As Object, ByVal e As EventArgs)
If Not IsNumeric(PageIndex) Then
PageIndex = CurrentPageIndex
End If
If PageIndex < 1 Then
PageIndex = 1
ElseIf PageIndex > PageCount Then
PageIndex = PageCount
End If
CurrentPageIndex = PageIndex
Call DataBind()
End Sub
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Private Sub lbFirstPage_Click()Sub lbFirstPage_Click(ByVal source As Object, ByVal e As EventArgs)
CurrentPageIndex = 1
Call DataBind()
End Sub
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Private Sub lbPrevPage_Click()Sub lbPrevPage_Click(ByVal source As Object, ByVal e As EventArgs)
If CurrentPageIndex > 1 Then
CurrentPageIndex -= 1
End If
Call DataBind()
End Sub
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Private Sub lbNextPage_Click()Sub lbNextPage_Click(ByVal source As Object, ByVal e As EventArgs)
If CurrentPageIndex < PageCount Then
CurrentPageIndex += 1
End If
Call DataBind()
End Sub
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Private Sub lbLastPage_Click()Sub lbLastPage_Click(ByVal source As Object, ByVal e As EventArgs)
CurrentPageIndex = PageCount
Call DataBind()
End Sub
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#End Region
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
下面的代码用于控件的下拉列表属性页
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
Public Class StoredProcedureNameConverterClass StoredProcedureNameConverter
Inherits StringConverter
'存储过程 有兴趣可以添加你自己的存储过程
'要用下拉列表编辑属性
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Overrides Function GetStandardValuesSupported()Function GetStandardValuesSupported(ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
'这个override返回下拉列表项。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Overrides Function GetStandardValues()Function GetStandardValues(ByVal context As ITypeDescriptorContext) As StandardValuesCollection
Dim StringArray As ArrayList = New ArrayList()
StringArray.Add("sys_QuickSortPaging")
StringArray.Add("sys_SortDataPager")
Return New StandardValuesCollection(StringArray)
End Function
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
'Return True的话只能选,Return flase可选可填
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Overrides Function GetStandardValuesExclusive()Function GetStandardValuesExclusive(ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function
End Class
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
Public Class ControlToDataBindConverterClass ControlToDataBindConverter
Inherits StringConverter
'列出可以绑定的控件
'要用下拉列表编辑属性
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Overrides Function GetStandardValuesSupported()Function GetStandardValuesSupported(ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
'这个override返回下拉列表项。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Overrides Function GetStandardValues()Function GetStandardValues(ByVal context As ITypeDescriptorContext) As StandardValuesCollection
Dim StringArray As ArrayList = New ArrayList()
Dim I As Long
Dim objControl As ControlCollection
objControl = CType(context.Container.Components(0), Page).Controls
For I = 0 To objControl.Count - 1
If TypeOf objControl(I) Is GridView Or TypeOf objControl(I) Is DataList Then
StringArray.Add(objControl(I).ClientID)
End If
Next
Return New StandardValuesCollection(StringArray)
End Function
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
'Return True的话只能选,Return false可选可填
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Overrides Function GetStandardValuesExclusive()Function GetStandardValuesExclusive(ByVal context As ITypeDescriptorContext) As Boolean
Return False
End Function
End Class
存储过程 为 SQL Server 2000版本,请打开SQL server 2000 的查询分析器执行下面的SQL 语句。
程序用到的存储过程(仅支持主键排序)
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sys_QuickSortPaging]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sys_QuickSortPaging]
GO
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CREATE PROCEDURE sys_QuickSortPaging
(
@Table nvarchar(4000), --表名(必须)
@PrimaryKeyField nvarchar(50), --表的主键字段
@Field nvarchar (4000)='*', --需要返回字段名(必须)
@Where nvarchar(1000)=NULL, --Where 条件(可选)
@GroupBy nvarchar(1000) = NULL, --分组
@OrderBy nvarchar(1000)=NULL, --排序用到的字段()
@PageNumber int = 1, --要返回的页(第X页) (默认为第一页)
@PageSize int = 10, --每页大小(默认为5)
@RecordCount int output --返回记录总数
)
AS
SET NOCOUNT ON
DECLARE @SortTable nvarchar(100)
DECLARE @SortName nvarchar(100)
DECLARE @strSortColumn nvarchar(200)
DECLARE @Operator nvarchar(50)
DECLARE @Type varchar(100)
DECLARE @Prec int
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
IF @OrderBy IS NULL OR @OrderBy = ''
SET @OrderBy = @PrimaryKeyField
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
/**//* 获取用于定位的字段*/
IF CHARINDEX('DESC',@OrderBy)>0
BEGIN
SET @strSortColumn = REPLACE(@OrderBy, 'DESC', '')
SET @Operator = '<='
END
ELSE
BEGIN
IF CHARINDEX('ASC', @OrderBy) = 0
SET @strSortColumn = REPLACE(@OrderBy, 'ASC', '')
SET @Operator = '>='
END
IF CHARINDEX('.', @strSortColumn) > 0
BEGIN
SET @SortTable = SUBSTRING(@strSortColumn, 0, CHARINDEX('.',@strSortColumn))
SET @SortName = SUBSTRING(@strSortColumn, CHARINDEX('.',@strSortColumn) + 1, LEN(@strSortColumn))
END
ELSE
BEGIN
SET @SortTable = @Table
SET @SortName = @strSortColumn
END
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
SELECT @Type=t.name, @Prec=c.prec
FROM sysobjects o
JOIN syscolumns c on o.id=c.id
JOIN systypes t on c.xusertype=t.xusertype
WHERE o.name = @SortTable AND c.name = @SortName
IF CHARINDEX('char', @Type) > 0
SET @Type = @Type + '(' + CAST(@Prec AS nvarchar) + ')'
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
DECLARE @strStartRow nvarchar(50)
DECLARE @strPageSize nvarchar(50)
DECLARE @strWhere nvarchar(1000)
DECLARE @strWhereAnd nvarchar(1000)
DECLARE @strGroupBy nvarchar(1000)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
IF @PageNumber < 1
SET @PageNumber = 1
SET @strPageSize = CONVERT (nvarchar(50), @PageSize)
SET @strStartRow = CONVERT ( nvarchar(50), (@PageNumber - 1)*@PageSize + 1)
IF @Where IS NOT NULL AND @Where !=''
BEGIN
SET @strWhere = ' WHERE '+ @Where
SET @strWhereAnd= ' AND ' + @Where
END
ELSE
BEGIN
SET @strWhere = ''
SET @strWhereAnd=''
END
IF @GroupBy IS NOT NULL AND @GroupBy != ''
BEGIN
SET @strGroupBy = ' GROUP BY ' + @GroupBy
END
ELSE
BEGIN
SET @strGroupBy = ''
END
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
DECLARE @strSQL nvarchar(4000)
SET @strSql= ' SELECT @RecordCount = Count (*) FROM ' + @Table + @strWhere + ' ' + @strGroupBy
EXEC sp_executesql @strSql,N'@RecordCount int OUTPUT',@RecordCount OUTPUT--计算总页数
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
EXEC
(
'
DECLARE @Sort ' + @Type + '
SET ROWCOUNT ' + @strStartRow + '
SELECT @Sort = ' + @strSortColumn + ' FROM ' + @Table + @strWhere + ' ' + @strGroupBy + ' ORDER BY ' + @OrderBy + '
SET ROWCOUNT ' + @strPageSize + '
SELECT '+@Field+' FROM ' + @Table + ' WHERE ' + @strSortColumn + @Operator + ' @Sort ' + @strWhereAnd + ' ' + @strGroupBy + ' ORDER BY ' + @OrderBy
)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
支持任意字段排序的存储过程
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sys_SortDataPager]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sys_SortDataPager]
GO
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CREATE PROCEDURE sys_SortDataPager (
@Table nvarchar(4000), --表名(必须)
@PrimaryKeyField nvarchar(50), --表的主键字段
@Field nvarchar (4000)='*', --需要返回字段名(必须)
@Where nvarchar(1000)=NULL, --Where 条件(可选)
@GroupBy nvarchar(1000) = NULL, --分组
@OrderBy nvarchar(1000)=NULL, --排序用到的字段()
@PageNumber int = 1, --要返回的页(第X页) (默认为第一页)
@PageSize int = 10, --每页大小(默认为5)
@RecordCount int out --返回记录总数
)
AS
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
/**//*Find the @PrimaryKeyField type*/
DECLARE @PKTable varchar(1000)
DECLARE @PKName varchar(1000)
DECLARE @type varchar(1000)
DECLARE @prec int
IF CHARINDEX('.', @PrimaryKeyField) > 0
BEGIN
SET @PKTable = SUBSTRING(@PrimaryKeyField, 0, CHARINDEX('.',@PrimaryKeyField))
SET @PKName = SUBSTRING(@PrimaryKeyField, CHARINDEX('.',@PrimaryKeyField) + 1, LEN(@PrimaryKeyField))
END
ELSE
BEGIN
SET @PKTable = @Table
SET @PKName = @PrimaryKeyField
END
SELECT @type=t.name, @prec=c.prec FROM sysobjects o JOIN syscolumns c on o.id=c.id JOIN systypes t on c.xusertype=t.xusertype
WHERE o.name = @PKTable AND c.name = @PKName
IF CHARINDEX('char', @type) > 0
SET @type = @type + '(' + CAST(@prec AS varchar) + ')'
DECLARE @strPageSize varchar(50)
DECLARE @strStartRow varchar(50)
DECLARE @strWhere varchar(1000)
DECLARE @strGroupBy varchar(1000)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
/**//*Default Sorting*/
IF @OrderBy IS NULL OR @OrderBy = ''
SET @OrderBy = @PrimaryKeyField
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
/**//*Default Page Number*/
IF @PageNumber < 1
SET @PageNumber = 1
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
/**//*Set paging variables.*/
SET @strPageSize = CAST(@PageSize AS varchar(50))
SET @strStartRow = CAST(((@PageNumber - 1)*@PageSize + 1) AS varchar(50))
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
/**//*Set filter & group variables.*/
IF @Where IS NOT NULL AND @Where != ''
SET @strWhere = ' WHERE ' + @Where + ' '
ELSE
SET @strWhere = ''
IF @GroupBy IS NOT NULL AND @GroupBy != ''
SET @strGroupBy = ' GROUP BY ' + @GroupBy + ' '
ELSE
SET @strGroupBy = ''
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
/**//*Execute dynamic query*/
DECLARE @strSQL nvarchar(4000)
SET @strSql= ' SELECT @RecordCount = Count (*) FROM ' + @Table + @strWhere + ' ' + @strGroupBy
EXEC sp_executesql @strSql,N'@RecordCount int OUTPUT',@RecordCount OUTPUT--计算总页数
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
EXEC(
'DECLARE @PageSize int
SET @PageSize = ' + @strPageSize + '
DECLARE @PrimaryKeyField ' + @type + '
DECLARE @tblPK TABLE (
PK ' + @type + ' NOT NULL PRIMARY KEY
)
DECLARE PagingCursor CURSOR DYNAMIC READ_ONLY FOR
SELECT ' + @PrimaryKeyField + ' FROM ' + @Table + @strWhere + ' ' + @strGroupBy + ' ORDER BY ' + @OrderBy + '
OPEN PagingCursor
FETCH RELATIVE ' + @strStartRow + ' FROM PagingCursor INTO @PrimaryKeyField
SET NOCOUNT ON
WHILE @PageSize > 0 AND @@FETCH_STATUS = 0
BEGIN
INSERT @tblPK (PK) VALUES (@PrimaryKeyField)
FETCH NEXT FROM PagingCursor INTO @PrimaryKeyField
SET @PageSize = @PageSize - 1
END
CLOSE PagingCursor
DEALLOCATE PagingCursor
SELECT ' + @Field + ' FROM ' + @Table + ' JOIN @tblPK tblPK ON ' + @PrimaryKeyField + ' = tblPK.PK ' + @strWhere + ' ' + @strGroupBy + ' ORDER BY ' + @OrderBy
)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
创建一个用于测试的表
CREATE TABLE [dbo].[Employees] (
[EmployeesID] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[LastName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[FirstName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[BirthDate] [datetime] NULL ,
[Address] [nvarchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
[City] [nvarchar] (18) COLLATE Chinese_PRC_CI_AS NULL ,
[HomePhone] [nvarchar] (24) COLLATE Chinese_PRC_CI_AS NULL ,
[Extension] [nvarchar] (4) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
生成 1000000 条测试数据
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[InsertTableData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[InsertTableData]
GO
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS OFF
GO
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CREATE PROCEDURE InsertTableData
AS
DECLARE @cnt bigint
SET @cnt = 0
WHILE @cnt < 1000000
BEGIN
INSERT INTO Employees(LastName,FirstName,BirthDate,Address,City,HomePhone,Extension)
Values
(
CAST('LastName ' +CONVERT(nvarchar(10), @cnt) as nvarchar(30)),
CAST('FirstName '+ CONVERT(nvarchar(10), @cnt) as nvarchar(30)),
GETDATE(),
CAST('Address IS No.'+ CONVERT(nvarchar(10), @cnt) as nvarchar(30)),
CAST('City '+ CONVERT(nvarchar(10), @cnt) as nvarchar(30)),
CAST('021-0000'+ LEFT(CONVERT(nvarchar(10), @cnt),4) as nvarchar(30)),
CAST('00' + LEFT(CONVERT(nvarchar(10), @cnt) ,1) as nvarchar(30))
)
SET @cnt = @cnt + 1
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)