您现在的位置是:网站首页> 编程资料编程资料
.NET实现Repeater控件+AspNetPager控件分页_实用技巧_
2023-05-24
312人已围观
简介 .NET实现Repeater控件+AspNetPager控件分页_实用技巧_
当然首先你要把bin文件放进你的项目,并加到你的工具栏去
//页头需引用的 <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> 控件部分(格式已经设计好)
后台绑定的代码
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" %><%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>通服产品