如何在网格视图中绑定数千条记录 [英] How to bind thousands of record in Grid view
本文介绍了如何在网格视图中绑定数千条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的一个表中有30,000条记录,我想在网格视图中显示所有记录.
我为此编写了一个传统代码来绑定网格视图,即
gvlist.DataSource = ds;
gvlist.DataBind();
我正在ds中获取并存储的所有数据,并将此DS提供给我的网格视图,但是大约3-4分钟需要花费很多时间来加载页面.
因此,建议尽量减少页面加载时间.
I have 30,000 record in my one table, and i want to show all record in grid view.
I write a traditional code for this to bind grid view i.e.
gvlist.DataSource =ds;
gvlist.DataBind();
all data i am fetching and storing in ds and i supply this DS to my grid view,but it is taking to much time to load page around 3-4 mins.
So any suggesstions to minimise page load time.
推荐答案
您需要为此使用分页.阅读有关gridview分页的更多信息.如果您使用Google,则有很多文章.
然后,在习惯了这一概念之后,您可能想尝试这一个. [ ^ ]
You need to use paging for this one. Read more about paging in gridview. There are a lot of articles if you use google.
And then, after you get used to the concept, you might want to try this one.[^]
根本不建议您在做什么.当用户数量增加时,您的网站可能会开始提供OutOfMemory
例外,许多用户会遇到超时.
使用 ^ ],以仅在页面上显示一定数量的记录.用户可以翻阅记录.您还可以扩展功能并为记录添加搜索功能.
同样,从数据库获取大量记录并使用分页时,还需要考虑某些性能.您有两件重要的事情要考虑:
a)服务器上的内存使用情况-如果一次获取大量记录,则DataTables将占用大量内存.
b)数据库命中率-更多的不是.的点击数,将需要更多的时间来处理页面.
您将必须优化网页以使用这两种技术的最佳组合来显示如此多的记录.
您也可以搜索Google/Bing,以显示Gridview中的大记录和性能注意事项.
希望这能给您一个开始. ! :thumbsup:
What you are doing is not at all recommended. When the number of users will increase, your website may start givingOutOfMemory
exceptions and many users will experience time-outs.
Use GridView paging[^] to display only certain number of records on a page. The user can page through the records. You may also extend the features and add search facility for the records.
Again, there are certain performance considerations when you are getting so many records from database and using paging. You have two important things to consider:
a) memory usage on the server - DataTables will take a lot of memory if huge records are fetched at a time.
b) database hits - more the no. of hits, more time it takes to process the page.
You will have to optimize your web page to use best combination of both the techniques display so many records.
You may also search Google/Bing for displaying large records in Gridview and performance considerations.
Hope this gives you a start. ! :thumbsup:
这篇关于如何在网格视图中绑定数千条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文