逐页显示网格视图中的数据 [英] Displaying data in grid view page by page

查看:124
本文介绍了逐页显示网格视图中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表中有三万多行。加载gridview中的所有数据需要很多时间。所以我想一次显示100行。当我点击下一页按钮时,应该显示另外100行。当我单击上一页按钮时,应显示前100行。如果我在文本框中输入第5页,那么我想跳转到第5行。



我还想显示有多少页面。我们可以在vb.net [winform] gridview中实现这个概念。我正在使用数据库PostgreSQL。



任何人可以给我一个提示或一些概念?

解决方案

请查看PostgreSQL中的 OFFSET和LIMIT 。< br>
您对第5页的查询可能如下所示:

  SELECT * 
FROM tbl
ORDER BY id
OFFSET 400
LIMIT 100;

id 主键在我的例子中,因此索引自动到位。
如果以这种方式访问​​表格很多,性能可能会从使用

总页数:

  SELECT ceil(1235 :: real / 100):: int 
FROM tbl;

如果您想要将数字四舍五入,只需简化为:

  SELECT 1235/100 
FROM tbl;

两个数字都是整数,结果将是一个整数类型,小数位数自动截断。但我想你需要在这里进行整理。


I have more than 30,000 rows in a table. It takes a lot of time to load all the data in the gridview. So I want to display 100 rows at a time. When I click next page button, another 100 rows should be displayed. When I click previous page button, previous 100 rows should be displayed. If I type page 5 in a text box, then I want to jump over to the 5th lot of rows.

I also want to display how many pages there will be. Can we implement this concept in vb.net [winform] gridview. I am using database PostgreSQL.

Can anybody give me a hint or some concept?

解决方案

Look at OFFSET and LIMIT in PostgreSQL.
Your query for the 5th page could look like this:

SELECT * 
FROM   tbl
ORDER  BY id
OFFSET 400
LIMIT  100;

id is the primary key in my example, therefore an index is in place automatically. If you access the table a lot in this fashion, performance may profit from using CLUSTER.

Total number of pages:

SELECT ceil(1235::real / 100)::int
FROM   tbl;

If you wanted the number rounded down, just simplify to:

SELECT 1235  / 100
FROM   tbl;

With both numbers being integer the result will be an integer type and fractional digits truncated automatically. But I think you need to round up here.

这篇关于逐页显示网格视图中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆