寻呼机制 [英] Paging Mechanism
问题描述
我处于在网格中处理大量记录的情况。而不是将所有记录绑定到网格中。为什么我们不应该绑定属于第5页的一组记录。
作为一个好习惯,不应该绑定所有记录从查询中直接检索到网格视图等控件,当然,除非你确定记录数很少。
这是因为当数字的记录是巨大的,页面加载速度较慢,因为绑定需要很多时间。
我在以前的项目中使用的一种方法是获取总数记录受查询影响。 (可以说他们是1000)。
然后用页面大小(比如100)来划分记录的数量。
现在我提供页面分页(1-10)。
当用户点击特定页面时,我使用 ROW_NUMBER()
函数获取与该页面有关的记录SQL。
查询将类似于
SELECT x,y, ROW_NUMBER()OVER(ORDER BY z asc)AS'RowNumber'
FROM t WHERE RowNumber>下限和RowNumber< UPPERLIMIT。
使用当前页码和页面大小计算下限和上限。
我希望这可以回答您的问题。
I am in the situation of working with large amount of records in a grid. Instead of, binding all records into the grid. why we should not bind set of records which are belongs to 5th page.
As a good practice one should not bind all the records retrieved from a query directly to a control such as grid view , unless of course you are absolutely sure that the number of records are few.
This is because when the number of records are huge, the page loads slower,since binding takes a lot of time.
One approach that I have used in my previous project is to fetch the total number of records affected by the query. (Lets say they are 1000).
I then divide the number of records with the page size (say 100).
So now I provide pagination with pages (1-10).
When the user clicks on a particular page, I fetch records pertaining to that page using ROW_NUMBER()
function in SQL.
The query will be something like
SELECT x, y, ROW_NUMBER() OVER(ORDER BY z asc) AS 'RowNumber'
FROM t WHERE RowNumber > lowerlimit and RowNumber < upperlimit.
Lowerlimit and upperlimit are calculated using the current page number and page size.
I hope this answers your question
这篇关于寻呼机制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!