All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET,2.0中合并,GridView,的表头单元格_[Asp.Net教程]
C#中正则表达式进行忽略大小写的字符串替换_[Asp.Net教程]
Repeater属性、方法和事件
Sys.ScriptLoader与JS加载进度条的实现_.net资料_编程技术
SQL,INNER,JOIN,关键字_mssql学习_编程技术
Asp.net,MVC2.0初级教程-添加操作_[Asp.Net教程]
以xml数据源作无限级联动下拉框_[Asp.Net教程]
GridView+FormView,示范数据:,新增、修改、删除(进阶篇:服务器控件)_[Asp.Net教程]
PHP技巧:详解phplib模板使用过程及运行原理_php资料_编程技术
Asp.net,2.0,用C#,创建,PDF文件(示例代码下载)_[Asp.Net教程]
Reading number is top 10 pictures
Female model behind the bitterness, often being overcharged2
Fierce! China's special forces training the devil1
Absolutely shocked. National geographic 50 animal photographys2
西游四格漫画(一)
The money of more than 100 countries and regions16
29 the belle stars after bath figure2
网上疯传的一篇小学作文《爸爸也治不了妈妈》
胸部遭到偷窥的女人们
Exquisite decoration is not paying too much4
Fan bingbing black wings for platform and DanLuoWang believes beauty2
Download software ranking
dreamweaver8中文版
Be there or be square
Tram sex maniac 2 (H) rar bag1
小黑猫大战两米大花蛇
Eclipse 4.2.2 For Win64
C#程序员参考手册
Unix video tutorial1
Adobe Flash Player(IE) 10.0.32.18 浏览器专用的FLASH插件
I'm come from Beijing1
c#程序设计案例教程
aaa published in(发表于) 2013/12/6 10:25:14 Edit(编辑)
ASP.NET技巧:DataGridView,的分页处理_.net资料_编程技术

ASP.NET技巧:DataGridView,的分页处理_.net资料_编程技术

ASP.NET技巧:DataGridView 的分页处理_.net资料_编程技术-数科优化网

只是解决DataGridview刷新慢的办法。
如果要考虑效率,还是结合分页的"存储过程"比较好,只是变通了一下。


1 #region 数据处理
2 ///


3 /// 得到期初数据
4 ///

5 private void getFillDateset()
6 {
7 try
8 {
9 //每页显示数
10 pageSize = 10;
11 //得到最大记录数
12 maxRec = dtSource.Rows.Count;
13 //共有多少页
14 pageCount = (maxRec / pageSize);
15 //取余数
16 if ((maxRec % pageSize) > 0)
17 {
18 pageCount++;
19 }
20 //默认第一页
21 currentPage = 1;
22 recNo = 0;
23 LoadPage();
24 }
25 catch
26 {
27 }
28 }
29
30
31 ///
32 /// 判断是否数据已经加载
33 ///

34 ///
35 private bool CheckFillButton()
36 {
37 if (pageSize == 0) return false;
38 else return true;
39 }
40
41 ///
42 /// 取DataTable的数据
43 ///

44 private void LoadPage()
45 {
46 int startRec;
47 int endRec;
48 DataTable dtTemp;
49
50
51 dtTemp = dtSource.Clone();
52 if (currentPage == pageCount) endRec = maxRec;
53 else endRec = pageSize * currentPage;
54 startRec = recNo;
55 for (int i = startRec; i < endRec; i++)
56 {
57 dtTemp.ImportRow(dtSource.Rows[i]);
58 recNo++;
59 }
60 this.dataGridView1.DataSource = dtTemp;
61 }
62
63 ///
64 /// 分页事件(取各个按键的Tag值)
65 ///

66 ///
67 ///
68 private void changepage(object sender, EventArgs e)
69 {
70 if (!CheckFillButton()) return;
71 int myint = Convert.ToInt16((string)(sender as Button).Tag);
72 switch (myint)
73 {
74 case 1:
75 if (currentPage == 1)
76 {
77 MessageBox.Show("The frist page now!");
78 return;
79
80 }
81 currentPage = 1;
82 recNo = 0;
83 LoadPage();
84 break;
85 case 2:
86 currentPage++;
87 if (currentPage > pageCount)
88 {
89 currentPage = pageCount;
90 if (recNo == maxRec)
91 {
92 MessageBox.Show("The last page now!");
93 return;
94 }
95 else
96 recNo = pageSize * (currentPage + 1);
97 }
98 LoadPage();
99 break;
100 case 3:
101 if (currentPage == pageCount)
102 recNo = pageSize * (currentPage - 2);
103 currentPage--;
104 if (currentPage < 1)
105 {
106 MessageBox.Show("The frist page now!");
107 currentPage = 1;
108 return;
109 }
110 else
111 recNo = pageSize * (currentPage - 1);
112
113 LoadPage();
114 break;
115
116 case 4:
117 if (!CheckFillButton()) return;
118 if (recNo == maxRec)
119 {
120 MessageBox.Show("The Last page now!");
121 return;
122 }
123 currentPage = pageCount;
124 recNo = pageSize * (currentPage - 1);
125 LoadPage();
126 break;
127 }
128
129 }
130
131 #endregion






添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.