Asp. NET, DataList and DataRepeater provide a simple and quick way to show the data,
<ItemTemplate> is a way for us to decide what we want to do with our data. Unfortunately, he
Unlike the DataGrid, there is a built-in paging function.
How do you solve this problem that cannot be divided into pages? In this article, we will introduce how to use PagedDataSource Class to solve the problem of the page.
Simple introduction to a few commonly used PagedDataSource Class public Properties
DataSource-Data source
Allowpaging-true allow a page to be allowed to be false.
PageSize-How many times did you decide to repeat
PageCount-A total of several pages
CurrentPageIndex-Current Pages
Isfirstpage-is the first page, echo True or False
Islastpage-Is it the last page, echo True or False
Here's the example (you can just run away with the clippings)
<%@ Page language= "VB"%>
<%@ import namespace= "System.Data"%>
<script runat= "Server" >
Sub Page_Load (Sender as Object, E as EventArgs)
Dim Pgds as PagedDataSource = New PagedDataSource ()
Pgds.datasource = CreateDataSource (). DefaultView
pgds.allowpaging = True
Pgds.pagesize = 6 ' Deciding how many times to duplicate
Lbltotalpage.text = Pgds.PageCount.ToString ()
Dim CurrentPage as Integer
If not Request.QueryString (' Page ') is nothing Then
Currentpage=convert.toint32 (Request.QueryString ("Page"))
Else
Currentpage=1
End If
If not Pgds.isfirstpage Then
Lnkprev.navigateurl=request.currentexecutionfilepath + "? Page= "+ convert.tostring (CurrentPage-1)
End If
If not Pgds.islastpage Then
Lnknext.navigateurl=request.currentexecutionfilepath+ "? Page= "+ convert.tostring (currentpage+1)
End If
Repeater1.datasource=pgds
Repeater1.databind ()
End Sub
Function CreateDataSource () as Datatable
' This is a example from ASP.net QuickStart
' You can change the ' this part with your own Dataset
Dim DT as DataTable
Dim Dr as DataRow
Dim I as Integer
' Create a DataTable
DT = New DataTable
Dt. Columns.Add (New DataColumn ("IntegerValue", GetType (Integer))
Dt. Columns.Add (New DataColumn ("StringValue", GetType (String))
Dt. Columns.Add (New DataColumn ("Datetimevalue", GetType (DateTime))
Dt. Columns.Add (New DataColumn ("Boolvalue", GetType (Boolean))
' Make some rows and put some sample data in
For i = 0 to 50
Dr = dt. NewRow ()
Dr (0) = i
DR (1) = "Item" + i.tostring ()
DR (2) = DateTime.Now.ToShortTimeString
If (i Mod 2 <> 0) Then
DR (3) = True
Else
DR (3) = False
End If
' Add the row to the DataTable
Dt. Rows.Add (DR)
Next
Http://cht.gotdotnet.com/quickstart/aspplus/doc/webdatabinding.aspx
</p>
<p>reference:msdn. NET Framework Class Library
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/ Frlrfsystemwebuiwebcontrolspageddatasourceclasstopic.asp
</p><p>
Paging with Repeater control in asp.net
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.