• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

datarepeater分页示例

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 18次 | 进入软件测试论坛讨论

领测软件测试网 <%@ 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>



延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网