AspNetPage分页(repeater)
当然首先你要把bin文件放进你的项目,并加到你的工具栏去 1 //页头需引用的
2 <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> 3 4 控件部分(格式已经设计好) 5 <webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True" FirstPageText="<font face='Webdings'>9</font>" 6 LastPageText="<font face='Webdings'>:</font>" NextPageText="<font face='Webdings'>8</font>" 7 PrevPageText="<font face='Webdings'>7</font>" ShowCustomInfoSection="Left" InputBoxStyle="width:19px" 8 TextAfterInputBox="页" TextBeforeInputBox="转到第" CustomInfoHTML="共检索到<strong>%RecordCount%</strong>条记录 页次:<strong>%CurrentPageIndex%/%PageCount%</strong> 每页<strong>%PageSize%</strong>条" 9 HorizontalAlign="Right" Width="100%" ShowInputBox="Always" OnPageChanged="AspNetPager1_PageChanged" 10 PageSize="20" ShowBoxThreshold="1"> 11 </webdiyer:AspNetPager> 12
后台绑定的代码 1 void databind()
2 { 3 int QYId = Convert.ToInt32(Request.Cookies["CompenyUser"].Value);//企业的Id 4 DataTable dt = bll.Viewlist(QYId); 5 this.AspNetPager1.RecordCount = dt.Rows.Count;//获取数据的总数 6 7 PagedDataSource pds = new PagedDataSource(); 8 pds.DataSource = dt.DefaultView;//为控件绑定数据 9 pds.AllowPaging = true;//分页启用 10 pds.PageSize = AspNetPager1.PageSize;//获取每页显示的数量 11 pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; 12 13 Repeater1.DataSource = pds; 14 Repeater1.DataBind(); 15 } 16 分页,只需要把绑定放在AspNetPager1_PageChanged 事件里 |