Repeater控件分页例子(ASP.NET 2.0)
2006-11-13 12:04
453 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Configuration;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.Security;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls.WebParts;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data.SqlClient;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
public partial class _Default : System.Web.UI.Page
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Page_Load(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (!IsPostBack)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RepeaterDataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void RepeaterDataBind()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string connectionString = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SqlConnection conn = new SqlConnection(connectionString);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Configuration rootWebConfig =
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
conn.Open();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SqlDataAdapter Adapter = new SqlDataAdapter("select firstname, lastname from Employees", conn);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
try
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Adapter.Fill(ds, "testTable");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PagedDataSource objPage = new PagedDataSource();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
objPage.DataSource = ds.Tables["testTable"].DefaultView;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
objPage.AllowPaging = true;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
objPage.PageSize = 5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int CurPage;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(Request.QueryString["Page"] != null)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CurPage = 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
objPage.CurrentPageIndex = CurPage - 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
lblCurPage.Text = "当前第" + CurPage.ToString()+"页";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!objPage.IsFirstPage)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!objPage.IsLastPage)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RepeaterPage.DataSource = objPage;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RepeaterPage.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
catch(Exception error)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Response.Write(error.ToString());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
finally
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
conn.Close();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- Repeater控件分页例子(ASP.NET 2.0)
- ASP.NET 2.0 Repeater控件分页例子
- asp.net Repeater使用例子,包括分页
- ASP.NET Repeater控件实现简单分页
- ASP.NET中Repeater控件实现分页功能
- Scott Mitchell 的ASP.NET 2.0数据教程之四十四::DataList和Repeater数据分页
- ASP.NET 2.0: Add build-in paging feature to repeater/为repeater添加内置分页功能
- ASP.NET 2.0 的数据绑定控件概述与区别(GridView、DetailsView、FormView 、Repeater、DataList)
- [原]ASP.NET(C#)Repeater分页控件(含源码)
- Scott Mitchell 的ASP.NET 2.0数据教程之四十四::DataList和Repeater数据分页
- asp.net repeater控件使用(自定义coulmn,分页)
- asp.net中repeater控件的嵌套和实现分页
- ASP.NET 2.0 中AspNetPager.dll控件的分页方法操作方法
- Pager Control for ASP.NET(asp.net分页控件例子)
- ASP.NET中Repeater控件实现分页功能
- ASP.NET 2.0 中AspNetPager.dll控件的分页方法操作方法
- Scott Mitchell 的ASP.NET 2.0数据教程之四十四::DataList和Repeater数据分页
- ASP.NET 2.0---Repeater控件
- asp.net动态网站repeater控件使用及分页操作介绍
- Asp.net 利用Repeater和ObjectDataSource 实现自定义分页控件