A paging function

xiaoxiao2021-03-06  44

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") I., = convert.toint32 (System.Web.httpContext.current.Request. QueryString ( "page")) Else curpage = 1 End If pds.CurrentPageIndex = curpage - 1 lblcurrentpage.Text = "Pages:" 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 the linknext.navigateURL = Format_URL () "Page =" Convert.TOSTRING (CURPAGE 1)

Endiff Return PDS Catch EX EX EXCETION END TRYEND FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-75093.html

New Post(0)