博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ASP.NET使用AspNetPager实现简单的分页功能
阅读量:6156 次
发布时间:2019-06-21

本文共 2851 字,大约阅读时间需要 9 分钟。


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

你可能感兴趣的文章
Silverlight 如何手动打包xap
查看>>
建筑电气暖通给排水协作流程
查看>>
JavaScript面向对象编程深入分析(2)
查看>>
linux 编码转换
查看>>
POJ-2287 Tian Ji -- The Horse Racing 贪心规则在动态规划中的应用 Or 纯贪心
查看>>
Windows8/Silverlight/WPF/WP7/HTML5周学习导读(1月7日-1月14日)
查看>>
关于C#导出 文本文件
查看>>
maclean liu的oracle学习经历--长篇连载
查看>>
分享:动态库的链接和链接选项-L,-rpath-link,-rpath
查看>>
Javascript一些小细节
查看>>
禁用ViewState
查看>>
Android图片压缩(质量压缩和尺寸压缩)
查看>>
nilfs (a continuent snapshot file system) used with PostgreSQL
查看>>
【SICP练习】150 练习4.6
查看>>
HTTP缓存应用
查看>>
KubeEdge向左,K3S向右
查看>>
DTCC2013:基于网络监听数据库安全审计
查看>>
CCNA考试要点大搜集(二)
查看>>
ajax查询数据库时数据无法更新的问题
查看>>
Kickstart 无人职守安装,终于搞定了。
查看>>