惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
宝玉的分享
宝玉的分享
博客园 - 司徒正美
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 三生石上(FineUI控件)
IT之家
IT之家
博客园 - Franky
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
Recent Announcements
Recent Announcements
Stack Overflow Blog
Stack Overflow Blog
T
Threatpost
aimingoo的专栏
aimingoo的专栏
博客园_首页
Know Your Adversary
Know Your Adversary
T
Threat Research - Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Security Latest
Security Latest
T
Tailwind CSS Blog
The Hacker News
The Hacker News
P
Palo Alto Networks Blog
Latest news
Latest news
G
GRAHAM CLULEY
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
A
Arctic Wolf
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
InfoQ
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 叶小钗
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
罗磊的独立博客
博客园 - 聂微东
Simon Willison's Weblog
Simon Willison's Weblog
Scott Helme
Scott Helme
T
Tenable Blog
O
OpenAI News
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 热门话题
美团技术团队

博客园 - 生活即技术

好久不更新了,忙的惭愧哦,思考一个应用 利用dataTable 排序的解决方法 项目中遇到的一些小问题及解决方法 常用代码 一个com+消息队列的例子 部署Com+ 2004我的爱,2005我的期待 加密解密相关 生成略缩图 论坛在线人数统计代码 上礼拜六犯的愚蠢错误 正则表达式(1) 用户控件的使用(二) 用户控件的使用(一) DataList的使用(二)自定义分页的实现 DataList的使用(1) DataGrid的使用(2)自定义分页 DataGrid的使用(1)
又一新的分页方法(转帖)
生活即技术 · 2004-11-19 · via 博客园 - 生活即技术

Repeater和DataList控件提供了一个快速、灵活的表现数据的方式,但是,它们没有内建的分页功能;DataGrid控件提供了内建的分页功能,但它的结构比较复杂。下面就用PagedDataSource类实现Repeater和DataList的分页。 PagedDataSource封装了DataGrid的分页属性,我们可以象DataGrid那样进行分页。代码如下:

<%@ Page Language="VB" %>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Public Sub Page_Load(ByVal src As ObjectByVal e As EventArgs) 
 
Dim objConn As OleDbConnection = New OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("../aspxWeb.mdb")) 
 
Dim objCommand As OleDbDataAdapter = New OleDbDataAdapter ("select * from Document", objConn) 
 
Dim ds As DataSet = New DataSet () 
 objCommand.Fill(ds) 
 
Dim objPds As PagedDataSource = New PagedDataSource () 
 objPds.DataSource 
= ds.Tables(0).DefaultView 
 objPds.AllowPaging 
= True 
 objPds.PageSize 
= 5 
 
Dim CurPage As Integer 
 
If Not (Request.QueryString("Page"Is NothingThen 
   CurPage 
= Convert.ToInt32(Request.QueryString("Page")) 
 
Else 
   CurPage 
= 1 
 
End If 
 objPds.CurrentPageIndex 
= CurPage - 1 
 lblCurrentPage.Text 
= "当前页:" + CurPage.ToString() 
 
If Not objPds.IsFirstPage Then 
   lnkPrev.NavigateUrl 
= Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1
 
End If 
 
If Not objPds.IsLastPage Then 
   lnkNext.NavigateUrl 
= Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1
 
End If 
 Repeater1.DataSource 
= objPds 
 Repeater1.DataBind() 
End Sub

</script>
<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>

真是学无止境也,解决问题的方法有好多种哟