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

推荐订阅源

T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Securelist
K
Kaspersky official blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
Forbes - Security
Forbes - Security
Spread Privacy
Spread Privacy
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Palo Alto Networks Blog
H
Hacker News: Front Page
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
S
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
I
InfoQ
人人都是产品经理
人人都是产品经理
PCI Perspectives
PCI Perspectives
月光博客
月光博客
爱范儿
爱范儿
Jina AI
Jina AI
WordPress大学
WordPress大学
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
博客园 - 司徒正美
Scott Helme
Scott Helme
AI
AI
L
LangChain Blog
A
Arctic Wolf
博客园 - 【当耐特】
量子位
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
腾讯CDC
博客园 - 叶小钗
Last Week in AI
Last Week in AI
S
Secure Thoughts

博客园 - 生活即技术

好久不更新了,忙的惭愧哦,思考一个应用 利用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>

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