当然首先你要把bin文件放进你的项目,并加到你的工具栏去

//页头需引用的
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

控件部分(格式已经设计好)
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True" FirstPageText="<font face='Webdings'>9</font>"
 LastPageText="<font face='Webdings'>:</font>" NextPageText="<font face='Webdings'>8</font>"
 PrevPageText="<font face='Webdings'>7</font>" ShowCustomInfoSection="Left" InputBoxStyle="width:19px"
 TextAfterInputBox="页" TextBeforeInputBox="转到第" CustomInfoHTML="共检索到<strong>%RecordCount%</strong>条记录 页次:<strong>%CurrentPageIndex%/%PageCount%</strong> 每页<strong>%PageSize%</strong>条"
 HorizontalAlign="Right" Width="100%" ShowInputBox="Always" OnPageChanged="AspNetPager1_PageChanged"
 PageSize="20" ShowBoxThreshold="1">
</webdiyer:AspNetPager>

后台绑定的代码

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();
    }

分页,只需要把绑定放在AspNetPager1_PageChanged 事件里

再给大家一个实例

前台页面代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TF_Product.aspx.cs" Inherits="TF_Product" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 
<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>通服产品</title>
  <script src="/UploadFiles/2021-04-02/jquery.js">

后台代码

Tb_productsHelper helper = new Tb_productsHelper();
    IList<Tb_productsInfo> 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();

标签:
Repeater控件,AspNetPager

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“.NET实现Repeater控件+AspNetPager控件分页”

暂无“.NET实现Repeater控件+AspNetPager控件分页”评论...