非数据库数据源分页的实现

作者:袖梨 2022-06-30
 
暂时测试地址:
202.127.144.107/overred/nodatapage.htm
下载地址:
chinaeduonline.net/rar/nodatapage.rar
里面有详细的说明
主要代码:
把ArrayList(或数组)的数据源绑定到repeater,并进行分页
+++demo++++
aspx
__________________________________________






<%#Container.DataItem%>





当前页: 
1



Label





____________________________________________________
.cs
____________________________________________________________
public class t1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label dq;
protected System.Web.UI.WebControls.Label link;
protected System.Web.UI.WebControls.Label d;
protected System.Web.UI.WebControls.Repeater rtestt;
protected System.Web.UI.WebControls.Repeater rtest;
private int pagesize;//每页显示的记录数目
public void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
pagesize=40; //每页显示的记录数目
this.rtest.DataSource=Datasource();//直接绑定到数据源
this.rtest.DataBind();
}
//设置ArrayList,供ArrayList Datasource()调用
public ArrayList Data()
{
//++++给repeater构造数据源,长度变量为j+++++++++++++++++++++++++++++++++++++++++++++++++++++
ArrayList s=new ArrayList();
for(int j=1;j<100;j++)
s.Add("aa"+j.ToString());
return s;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

相关文章

精彩推荐