datarepeater分頁樣本

來源:互聯網
上載者:User
分頁|樣本 <%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)

Dim Pgds As PagedDataSource = New PagedDataSource
Pgds.DataSource = CreateDataSource().DefaultView
Pgds.AllowPaging = True
Pgds.PageSize = 6
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

Pgds.CurrentPageIndex = CurrentPage - 1
lblCurrentPage.Text = CurrentPage.ToString()

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

Dim dt As DataTable
Dim dr As DataRow
Dim i As Integer

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)))

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

dt.Rows.Add(dr)
Next

Return dt

End Function

</script>
<html>
<head>
<title>DataRepeater</title>
<style type=text/css>

BODY {FONT: 10px Verdana, Arial, Helvetica, "sans serif"; COLOR: #000000; }
.txt {FONT-SIZE: 12px}
</style>
</head>
<body>
<form id="Form1" name=form1 method=post runat="server">
<table class=txt width="100%" border=0>
<tbody>
<tr>
<td> <asp:hyperlink id=lnkPrev runat="server">上頁</asp:hyperlink> <asp:hyperlink id=lnkNext runat="server">下頁</asp:hyperlink>

<asp:label id=lblCurrentPage runat="server"></asp:label>
頁 共
<asp:label id=lblTotalPage runat="server"></asp:label>
頁 </td>
</tr></tbody>
</table>
<asp:repeater ID=Repeater1 runat="server">
<itemtemplate>
<hr align="left" width="60%" size="1">
<table class=txt width="100%" border="0">
<tr>
<td>Order Date:
<%# DataBinder.Eval(Container.DataItem, "DateTimeValue", "{0:d}") %></td>
<tr>
<td>Quantity:
<%# DataBinder.Eval(Container.DataItem, "IntegerValue", "{0:N2}") %></td>
<tr>
<td>Item:
<%# DataBinder.Eval(Container.DataItem, "StringValue") %></td>
<tr>
<td>Order Date:
<asp:checkbox id="chk1" checked=<%# DataBinder.Eval(Container.DataItem, "BoolValue")%> runat="server"/>
</td>
</tr>
</table>
</itemtemplate>
</asp:repeater>
<hr hight="1">
</form>
</body>
</html>





相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。