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

推荐订阅源

H
Hacker News: Front Page
博客园_首页
大猫的无限游戏
大猫的无限游戏
有赞技术团队
有赞技术团队
Microsoft Azure Blog
Microsoft Azure Blog
Recorded Future
Recorded Future
博客园 - Franky
Application and Cybersecurity Blog
Application and Cybersecurity Blog
U
Unit 42
S
Secure Thoughts
博客园 - 司徒正美
美团技术团队
C
Cisco Blogs
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
V
Vulnerabilities – Threatpost
T
Troy Hunt's Blog
S
Security Affairs
爱范儿
爱范儿
AWS News Blog
AWS News Blog
Help Net Security
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
T
Threatpost
F
Fortinet All Blogs
Scott Helme
Scott Helme
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog RSS Feed
O
OpenAI News
S
Schneier on Security
Stack Overflow Blog
Stack Overflow Blog
T
Tor Project blog
AI
AI
D
DataBreaches.Net
PCI Perspectives
PCI Perspectives
T
Tailwind CSS Blog
Martin Fowler
Martin Fowler
P
Palo Alto Networks Blog
C
CERT Recently Published Vulnerability Notes
腾讯CDC
T
Tenable Blog
人人都是产品经理
人人都是产品经理
Recent Announcements
Recent Announcements
C
Cyber Attacks, Cyber Crime and Cyber Security
Jina AI
Jina AI
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google Online Security Blog
Google Online Security Blog
S
Securelist
P
Proofpoint News Feed
L
LINUX DO - 最新话题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

博客园 - 生活即技术

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

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