.NET implements Repeater control + AspNetPager control paging

高洛峰
Release: 2017-02-08 09:20:03
Original
1392 people have browsed it

Of course first you have to put the bin file into your project and add it to your toolbar

//页头需引用的 <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> 控件部分(格式已经设计好)  
Copy after login

Background binding code

void databind() { int QYId = Convert.ToInt32(Request.Cookies["CompenyUser"].Value);//企业的Id DataTable dt = bll.Viewlist(QYId); this.AspNetPager1.RecordCount = dt.Rows.Count;//获取数据的总数 PagedDataSource pds = new PagedDataSource(); pds.DataSource = dt.DefaultView;//为控件绑定数据 pds.AllowPaging = true;//分页启用 pds.PageSize = AspNetPager1.PageSize;//获取每页显示的数量 pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; Repeater1.DataSource = pds; Repeater1.DataBind(); }
Copy after login

Paging, just put the binding in the AspNetPager1_PageChanged event

Let me give you another example

Foreground page code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TF_Product.aspx.cs" Inherits="TF_Product" %>  <%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>   通服产品           
【登陆】【注册】
首页 > 通服产品 返回首页
产品类别: 关键字:
产品型号: <%#Eval("pr_guige")%>查看详情
产品编码: <%#Eval("pr_bianma")%>
产品描述: <%#Eval("pr_ms")%>
Copy after login

Backend code

Tb_productsHelper helper = new Tb_productsHelper(); IList list = helper.GetAllListBySql(product_sql); this.AspNetPager1.RecordCount = list.Count;//绑定总数量 this.AspNetPager1.AlwaysShow = true; //先声明一个分页类对象 PagedDataSource ps = new PagedDataSource(); ps.AllowPaging = true; ps.PageSize = this.AspNetPager1.PageSize; ps.CurrentPageIndex = this.AspNetPager1.CurrentPageIndex-1; ps.DataSource = list; this.rp.DataSource = ps; this.rp.DataBind();
Copy after login

For more .NET implementation of Repeater control + AspNetPager control paging related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!