如何处理gridview asp.net中的百万条记录 [英] How to handle million of record in gridview asp.net

查看:69
本文介绍了如何处理gridview asp.net中的百万条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在asp的gried视图中启用分页.但是记录数超过一百万,因此这是在这种情况下处理分页的最佳方法.请尽快给我建议. h2_lin>解决方案

分页很好,但涉及数百万条记录时,请确保仅获取所需的数据子集.

您可以提供起始于的记录号以及从该起始点检索的最大记录数.这使您可以基于当前页索引从数据源中仅检索记录的子集.您所需要做的就是跟踪当前记录索引.

您可以将记录索引存储在viewstate或=服务器上运行的隐藏字段中.

因此,在您第一次加载时,请将pageindex设置为0并说您显示20条记录.
单击下一个时,更新页面索引(pageindex ++).
例如,当您单击第8页时,将页面索引设置为8,依此类推.

现在,当您从数据库中获取记录时,请提取pageindex 8的数据.
要获取记录号,
fromrecord = pageindex * displayrecordno
torecord = fromrecord + displayrecordno

在例如displayrecordno = 20

希望这会有所帮助.
欢呼


这不是问题的有效表述.即使您可以实现最佳且最快的分页,一页上的项目数是多少?最多20、50、100,否则管理不善.一百万意味着用户需要至少单击5,000次向下翻页"才能到达数据集的中间.完全不现实.

因此,分页"的整个思想无法使您免于无法承受的压倒性的数据量.您还需要其他东西.例如,您可以通过某个键创建两步式层次结构(通常,这是按字母顺序排列的,并按首字母顺序列出).多级层次结构(实际上,几乎不超过2或3级)可以显示为具有选择项的项目列表,因此选择就像子查询一样,在给定控件的右侧重新填充项.此外,您可以为用户提供要显示在单个请求上的总记录的估计值,并建议缩小查询范围.您可以根据查询结果为用户提供帮助,但这可能是一项明智的技术,需要大量的思考.

这里的主要问题是:没有一个通用的最佳解决方案,因为这基本上都应取决于数据的结构以及所讨论的UI和整个应用程序的目的.您只能获得不同的想法,并在您的案例中采用它们.如果需要更多思考,请尝试在Web上寻找优质的海量数据应用程序,看看它们如何显示查询,结果和导航.

—SA


I want to enable paging in gried view in asp.But numbers of record is more million so which will be best approach to handle paging in such situation.Please give me suggestion as soon as possible.Please.

解决方案

Paging is fine but when it comes to millions of records, be sure to fetch the required subset of data only.

You can provide the record number start with and the maximum records to retrieve from that starting point. This enables you to retrieve only a subset of records from the datasource based on the current page index. All you need is to keep track of the the current record index.

You can store the record index in viewstate or in hidden fields run at = server.

So, while you first load, set the pageindex to 0 and say you display 20 records.
When the next is clicked, update the page index (pageindex++).
Say when you click 8th page, set the page index to 8 and so on.

Now, when you fetch the record from database, pull the data for pageindex 8.
To get the record number,
fromrecord = pageindex*displayrecordno
torecord = fromrecord+displayrecordno

In the e.g. displayrecordno=20

Hope this helps.
cheers


This is not a valid formulation of the problem. Even with the very best and fasted paging you can possibly achieve, what would be the number of items on a page? 20, 50, 100 at best, otherwise it''s not well manageable. A million means the user needs to click "page down" at least some 5,000 times just to reach the middle of the data set. Totally not realistic.

So, the whole idea of "paging" cannot save you from prohibitively overwhelming volumes of data. You need something else. For example, you can create two-step hierarchy by some key (very usually, it''s the alphabetical order with listing by first letter). Multi-level hierarchy (in practice, hardly more than 2 or 3 levels) could be presented as the lists of items with selection, so the selection acts like a sub-query, re-populating items on the right of the given control. Also, you can give the user the estimate of a total records to be shown on a single request and suggest to narrow down the query. You can assist the user based on the query results, but it could be a smart technique, needs a lot of thinking.

Main thing here is: there is no one universal recipe for best solution, because it all should essentially depend on the structure of your data and the purpose of the UI in question and the whole application. You can only get different ideas and adopt them for your case. For some more food for thought, try to look for good massive data applications on the Web to see how they present queries, results and navigation.

—SA


这篇关于如何处理gridview asp.net中的百万条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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