DataList分页

来源:互联网 发布:点云数据三维重建 编辑:程序博客网 时间:2024/04/28 11:35
Repeater和DataList控件提供了一个快速、灵活的表现数据的方式,但是,它们没有内建的分页功能;DataGrid控件提供了内建的分页功能,但它的结构比较复杂。下面就用PagedDataSource类实现Repeater和DataList的分页。 PagedDataSource封装了DataGrid的分页属性,我们可以象DataGrid那样进行分页。代码如下:
<html>
<head>
<title>Repeater控件分页的例子</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
  P,TD,DIV,SPAN {font-size:9pt}
</style>
</head>
<body>
<form name="form1" method="POST" runat="server">
<div style="padding:5px;background-color:#dedede">
<asp:label ID="lblCurrentPage" runat="server"></asp:label></td>
  <td>&nbsp;<asp:HyperLink id="lnkPrev" runat="server">上一页</asp:HyperLink>
  <asp:HyperLink id="lnkNext" runat="server">下一页</asp:HyperLink>&nbsp;
</div>
<hr size="1" color="#000099"/>
<asp:Repeater ID="Repeater1" runat="server">
<Itemtemplate>
<div style="padding:5px;background-color:#dedede">
<%# DataBinder.Eval(Container.DataItem, "Title") %>
</div>
</Itemtemplate>
</asp:Repeater>
</form>
</body>
</html>
 
原创粉丝点击