Imports System.Data
Imports System.Web.UI
Imports System.Web
Partial Public Class WebForm1
Inherits System.Web.UI.Page
'<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'End Sub
'Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
' InitializeComponent()
'End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
btnFirst.Text = "最首页"
btnPrev.Text = "前一页"
btnNext.Text = "下一页"
btnLast.Text = "最后页"
If Not Page.IsPostBack Then
ShowStats()
'lblCurrentIndex.Text = "第 " + (dgSortReport.CurrentPageIndex + 1).ToString() + "页"
'lblPageCount.Text = "总共 " + dgSortReport.VirtualItemCount.ToString() + " 页"
'sql(dgSortReport.CurrentPageIndex + 1)
End If
End Sub
Sub dgSortReport_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
dgSortReport.CurrentPageIndex = (e.NewPageIndex + 1)
'ShowStats()
sql(dgSortReport.CurrentPageIndex + 1)
End Sub
Protected Sub sql(ByVal CurrentPageIndex As Integer)
Dim tb, col, collist, condition As String
'查询的表名
tb = "sign"
'排序列的列名
col = "signid"
'返回的列名列表
collist = "signid,datetime,employeeName,late,quit"
'查询的表件
condition = "signid>0"
Dim coltype, orderby, pagesize, page As Integer
coltype = 0
orderby = 0
pagesize = 10
page = CurrentPageIndex
DBSet = GetResult(tb, col, collist, condition, coltype, orderby, page, pagesize, ErrorMsg)
dgSortReport.VirtualItemCount = Pages
dgSortReport.DataSource = DBSet.Tables(0).DefaultView
dgSortReport.CurrentPageIndex = 0
dgSortReport.DataBind()
End Sub
Sub ShowStats()
lblCurrentIndex.Text = "第 " + (dgSortReport.CurrentPageIndex + 1).ToString() + " 页"
lblPageCount.Text = "总共 " + dgSortReport.VirtualItemCount.ToString() + " 页"
sql(dgSortReport.CurrentPageIndex + 1)
End Sub
Sub PagerButtonClick(ByVal sender As Object, ByVal e As EventArgs)
Dim arg As String = sender.CommandArgument
Select Case arg
Case "next"
If (dgSortReport.CurrentPageIndex < (dgSortReport.VirtualItemCount - 1)) Then
dgSortReport.CurrentPageIndex += 1
End If
Case "prev"
If (dgSortReport.CurrentPageIndex > 0) Then
dgSortReport.CurrentPageIndex -= 1
End If
Case "last"
dgSortReport.CurrentPageIndex = (dgSortReport.VirtualItemCount - 1)
Case Else
dgSortReport.CurrentPageIndex = System.Convert.ToInt32(arg)
End Select
'ShowStats()
lblCurrentIndex.Text = "第 " + (dgSortReport.CurrentPageIndex + 1).ToString() + " 页"
lblPageCount.Text = "总共 " + dgSortReport.VirtualItemCount.ToString() + " 页"
sql(dgSortReport.CurrentPageIndex + 1)
End Sub
End Class
9 个解决方案
#1
帮顶啊~~
#2
谢谢了急呀!!
#3
这种大部分都是出在自己的分页逻辑代码有问题,自己慢慢调试下就可以了
#4
这东西没研究过,学习一下
#5
自己慢慢调试
#6
脑壳都整莽了
#7
慢慢看吧,嘿嘿嘿!
#8
如果数据库是sql server的,建议将分页写在数据库的存储过程中,然后调用,sql server版有该存储过程,这样维护和性能都比较好
#9
这个就是调用的分页存储过程
#1
帮顶啊~~
#2
谢谢了急呀!!
#3
这种大部分都是出在自己的分页逻辑代码有问题,自己慢慢调试下就可以了
#4
这东西没研究过,学习一下
#5
自己慢慢调试
#6
脑壳都整莽了
#7
慢慢看吧,嘿嘿嘿!
#8
如果数据库是sql server的,建议将分页写在数据库的存储过程中,然后调用,sql server版有该存储过程,这样维护和性能都比较好
#9
这个就是调用的分页存储过程