ASP.NET使用AspNetPager实现简单的分页功能


ContractedBlock.gif ExpandedBlockStart.gif View Code
 
   
1 /// <summary>
2 /// 历史记录
3 /// </summary>
4   private static int sumcount;
5 private void BindHistory()
6 {
7 this .gdvHistory.DataSource = null ;
8 this .gdvHistory.DataBind();
9 DataTable table = null ;
10 DateTime dtst = Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 00:00:00 " );
11 DateTime dtend = Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 23:59:59 " );
12 try
13 {
14 table = _service.getOrderInfosHistory(officeInfo.ofNote1, 0 , 0 , 0 , officeInfo.ofLogin, 13 , - 1 , dtst, dtend);
15 if (table != null )
16 {
17 if (table.Rows.Count > 0 )
18 {
19 DataRow[] successRows = table.Select( " 订单状态='缴费成功' " );
20 int suMoney = 0 ;
21 foreach (DataRow item in successRows)
22 {
23 suMoney += Convert.ToInt32(item[ " 交易金额 " ] ?? " 0 " );
24 }
25 DataRow[] paRows = table.Select( " 订单状态='缴费失败' " );
26 int paMOney = 0 ;
27 foreach (DataRow item in paRows)
28 {
29 paMOney += Convert.ToInt32(item[ " 交易金额 " ] ?? " 0 " );
30 }
31 DataRow[] SubRows = table.Select( " 订单状态='提交缴费' " );
32 int SubOney = 0 ;
33 foreach (DataRow item in SubRows)
34 {
35 SubOney += Convert.ToInt32(item[ " 交易金额 " ] ?? " 0 " );
36 }
37 this .AspNetPager1.Visible = true ;
38 sumcount = table.Rows.Count;
39 PagedDataSource pds = new PagedDataSource();
40 AspNetPager1.RecordCount = sumcount;
41 pds.AllowPaging = true ;
42 pds.PageSize = AspNetPager1.PageSize;
43 pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1 ;
44 pds.DataSource = table.DefaultView;
45 this .gdvHistory.DataSource = pds;
46 this .gdvHistory.DataBind();
47 this .AspNetPager1.CustomInfoHTML = string .Format( " 当前第{0}/{1}页 共{2}条记录 其中成功{3}笔,总金额{4}元 失败{5}笔,总金额{6}元 提交{7}笔,总金额{8}元 " , new object [] { this .AspNetPager1.CurrentPageIndex, this .AspNetPager1.PageCount, this .AspNetPager1.RecordCount, successRows.Length, suMoney, paRows.Length, paMOney, SubRows.Length, SubOney });
48 }
49 else
50 {
51 this .AspNetPager1.Visible = false ;
52 }
53
54 }
55 else
56 {
57 this .AspNetPager1.Visible = false ;
58 }
59 }
60 catch { }
61 }

这是后台代码,前台页面代码如下

ContractedBlock.gif ExpandedBlockStart.gif View Code
 
   
1 < webdiyer:AspNetPager ID = " AspNetPager1 "
2 CssClass = " paginator " CurrentPageButtonClass = " cpb " runat = " server " AlwaysShow = " True "
3
4   FirstPageText = " 首页 " LastPageText = " 尾页 " NextPageText = " 下一页 " PageSize = " 18 "
5 PrevPageText = " 上一页 " ShowCustomInfoSection = " Left "
6
7   ShowInputBox = " Never " onpagechanged = " AspNetPager1_PageChanged " Visible = " false "
8 CustomInfoTextAlign = " Left " LayoutType = " Table " Wrap = " False " BorderStyle = " None "
9 ButtonImageAlign = " Middle " HorizontalAlign = " Right " NumericButtonCount = " 6 "
10 Font - Size = " Smaller " >
11 </ webdiyer:AspNetPager >
其中 webdiyer是引用2,<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

转载于:https://www.cnblogs.com/wsl2011/archive/2011/05/30/2063502.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值