我改成用datalist控件显示了。但还是不得。请帮帮看看吧!
Public Class showsmall
Inherits System.Web.UI.Page
Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Server.mappath("database.mdb"))
Dim flo, currentpages, currentp As Integer
...
Private Sub Page_Load(...)
If Not Page.IsPostBack Then
currentpages = 0
currentp = 0
Call sortpage()
End If
end sub
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")
datalist1.DataSource = ds
datalist1.DataBind()
conn.Close()
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
imb1.Enabled = True
imb2.Enabled = False
End If
End Sub
Private Sub imb1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs)
currentpages = currentp
currentpages = currentpages - 1' 上一页
Call sortpage()
currentp = currentpages
End Sub
Private Sub imb2_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs)
currentpages = currentp
currentpages = currentpages + 1' 下一页
Call sortpage()
currentp = currentpages
End Sub