分页时出现的小问题~
我在用datagrid自定义分页时,出现点问题。就是当记录数小于等于2时就会出错:
代码如下:其中lb和lb2是textbox控件,请帮看看!
Private sub page_load(...)
call sortpage()
...
end sub
Sub sortpage()
Dim pag As Integer
pag = Convert.ToInt32(lb2.Text)
conn.Open()
Dim adt As New OleDbDataAdapter("select * from mainwz,members where mainwz.users=members.memberuser and mainwz.titleid=" & Request.QueryString("tid") & " order by carticleid", conn)
Dim ds As New DataSet
adt.Fill(ds, "mainwz,members")
Dim fy As PagedDataSource = New PagedDataSource
fy.DataSource = ds.Tables("mainwz,members").DefaultView()
fy.AllowPaging = True
fy.PageSize = 2
fy.CurrentPageIndex = pag - 1
lb.Text = (fy.PageCount).ToString()
imb1.Enabled = True
imb2.Enabled = True
If Convert.ToInt32(lb2.Text) = 1 Then
imb1.Enabled = False
ElseIf Convert.ToInt32(lb2.Text) = fy.PageCount Then
imb2.Enabled = False
End If
dg1.DataSource = fy
dg1.DataBind()
conn.Close()