Public Shared Function page_split(ByVal sql As String, ByVal lblcurrentpage As Label, ByVal linkpre As HyperLink, ByVal linknext As HyperLink) As PagedDataSource
Try
Dim myconnection As New OleDbConnection(conn.connstring)
myconnection.Open()
'Dim sql As String = "select * from master"
Dim dscommand As New OleDbDataAdapter(sql, myconnection)
Dim mydataset As DataSet = New DataSet
dscommand.Fill(mydataset, "table0")
'mydatagrid.DataSource = mydataset.Tables("table0").DefaultView
'mydatagrid.DataBind()
Dim pds As PagedDataSource = New PagedDataSource
pds.DataSource = mydataset.Tables("table0").DefaultView
pds.AllowPaging = True
pds.PageSize = 10
Dim curpage As Integer
If Not (System.Web.HttpContext.Current.Request.QueryString("page") Is Nothing) Then
curpage = Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString("page"))
Else
curpage = 1
End If
pds.CurrentPageIndex = curpage - 1
lblcurrentpage.Text = "页数:" + curpage.ToString() + "/" + pds.PageCount.ToString
If Not pds.IsFirstPage Then
linkpre.NavigateUrl = format_url() + "page=" + Convert.ToString(curpage - 1)
End If
If Not pds.IsLastPage Then
linknext.NavigateUrl = format_url() + "page=" + Convert.ToString(curpage + 1)
End If
Return pds
Catch ex As Exception
End Try
End Function