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

推荐订阅源

Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
V
V2EX - 技术
S
Secure Thoughts
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
S
Securelist
S
Security Archives - TechRepublic
Know Your Adversary
Know Your Adversary
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
Recent Commits to openclaw:main
Recent Commits to openclaw:main
G
GRAHAM CLULEY
H
Hacker News: Front Page
Microsoft Azure Blog
Microsoft Azure Blog
I
Intezer
Google Online Security Blog
Google Online Security Blog
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Webroot Blog
Webroot Blog
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
P
Proofpoint News Feed
The Cloudflare Blog
I
InfoQ
L
LangChain Blog
U
Unit 42
P
Proofpoint News Feed
S
Schneier on Security
S
Security Affairs
Y
Y Combinator Blog
T
Tenable Blog
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
量子位
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
博客园 - 聂微东
D
Darknet – Hacking Tools, Hacker News & Cyber Security
GbyAI
GbyAI
AWS News Blog
AWS News Blog

博客园 - 简约旋律

如何做一名优秀的部门经理 viewstate 的工作原理 char与varchar的区别 堂堂正正做人 认认真真做事 笨鸟 节约时间 ASP.NET中的FILE对象总结 当梦想照进现实 (C#) C#中的@符号 数据库事务 读写删文件代码 什么是SQL注入及SQL注入工具 void的使用 导航树扩展 按F5运行时出现目录清单 - 简约旋律 经典JS收藏 GET POST的使用 关于request的一个问题 一些代码
Repeater/DataList分页方法
简约旋律 · 2007-11-22 · via 博客园 - 简约旋律

关于Repeater和DataList控件分页,我习惯用二种方法实现,其一就是利用PagedDataSource类来实现,相对简单一些,方法一如下:

  public void ListBind()
  {
   myConn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("/data/data.mdb"));
   OleDbDataAdapter myComm=new OleDbDataAdapter("select * from guestbook order by gbdate desc",myConn);
   DataSet ds=new DataSet();
   myComm.Fill(ds,"guestbook");

   PagedDataSource pds=new PagedDataSource();
   pds.DataSource=ds.Tables["guestbook"].DefaultView;
   pds.AllowPaging=true;
   pds.PageSize=8;

   int CurrentPage;
   if(Request.QueryString["Page"]!=null)
    CurrentPage=Convert.ToInt32(Request.QueryString["Page"]);
   else
    CurrentPage=1;
   pds.CurrentPageIndex=CurrentPage-1;
   lblCurrentPage.Text=CurrentPage.ToString();
   lblPageCount.Text=pds.PageCount.ToString();
   if(!pds.IsFirstPage)
   {
    lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToInt32(CurrentPage-1);
    lnkFirst.NavigateUrl=Request.CurrentExecutionFilePath+"?Page=1";
   }
   if(!pds.IsLastPage)
   {
    lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToInt32(CurrentPage+1);
    lnkLast.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+pds.PageCount;
   }
   dlstGuestbook.DataSource=pds;
   dlstGuestbook.DataBind();
  }