我想问一下分页的问题;就是我在分页时按下页不能显示下页的数据,仍然是显示当前的数据。请问这是怎么回事,请指点一下,谢谢!
代码如下:
Sub sortpage()
Dim totaljl, pagesizes, totalpage, starts As Integer
pagesizes = 2
conn.Open()
Dim comm1 As New OleDbCommand("select count(*) as num from mainwz,members where mainwz.users=members.memberuser and mainwz.titleid=" & Request.QueryString("tid") & " ", conn)
Dim dr1 As OleDbDataReader = comm1.ExecuteReader()
If dr1.Read Then
totaljl = dr1.Item("num") '计算总记录
End If
dr1.Close()
lb2.Text = currentpages.ToString + 1
If (totaljl Mod pagesizes) = 0 Then '计算总页数
totalpage = totaljl / pagesizes
Else
totalpage = totaljl \ pagesizes + 1
End If
lb.Text = totalpage.ToString
starts = currentpages * pagesizes
Dim adt As New OleDbDataAdapter("select * from mainwz,members where mainwz.users=members.memberuser and mainwz.titleid=" & Request.QueryString("tid") & " order by floor", conn)
Dim ds As New DataSet
adt.Fill(ds, starts, pagesizes, "mainwz,members")
imb1.Enabled = True
imb2.Enabled = True
If totalpage = 1 Then
imb1.Enabled = False
imb2.Enabled = False
ElseIf totalpage > 1 And currentpages < totalpage Then
imb1.Enabled = False
imb2.Enabled = True
ElseIf totalpage > 1 And currentpages <= totalpage Then
imb2.Enabled = False
imb1.Enabled = True
End If
dg1.DataSource = ds
dg1.DataBind()
End Sub
Private Sub imb1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs)
currentpages = dg1.CurrentPageIndex - 1 '显示上一页的按钮
Call sortpage()
End Sub
Private Sub imb2_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs)
currentpages = dg1.CurrentPageIndex + 1 '显示下一页的按钮
Call sortpage()
End Sub