当数据源有2万行数据时,显示速度太慢了?如何提高显示速度? [英] When the datasource have 20 thousand rows of data,the speed to show it is so slow?How to improve the speed to show it?

查看:126
本文介绍了当数据源有2万行数据时,显示速度太慢了?如何提高显示速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是gridview.datasource = a(一个是列表,其中有2万个),速度太慢了;
我的想法是,当用户首次进入网页时,我设置了gridview.datasource = a1(a1是a中的前一千行数据);
然后我设置gridview.datasource = a1(a1是a中的前两千行数据);
....
然后我设置了gridview.datasource = a19(a1是a中的前19000行数据);
然后我设置了gridview.datasource = a20(a1是a中的前2万行数据);

但似乎不起作用,如何解决?

您能给我一个使用gridvie在网页中快速显示大量数据的示例吗?谢谢!

My code is gridview.datasource=a (a is list<studeng> whcih has 20 thousand ),the speed is so slow;
my idea is when user firstly enter the web page , I set gridview.datasource=a1 (a1 is the first 1 thousand rows of data in a);
and than I set gridview.datasource=a1 (a1 is the first 2 thousand rows of data in a);
....
and than I set gridview.datasource=a19 (a1 is the first 19 thousand rows of data in a);
and than I set gridview.datasource=a20 (a1 is the first 20 thousand rows of data in a);

but it seems doesn''t work, how to solve it ?

Can you give me some example to use gridvie to show large amount of data quick in a web page?Thank you!

推荐答案

您可能应该使用内置的分页功能GridView类的名称(请参见此示例 [ ^ ])

网页上有很多数据,请仔细考虑:
假设您只有一列,每个条目为空,并且编码为UTF-8
GridView将生成一个表,每一行都需要< tr>"和</tr>" (9个字节),并且每个项目都需要< td>"和</td>" (9个字节),因此:
20000 *(每行9个字节+每行1个项目*每项9个字节)= 360,000字节,仅用于带有一列的标记.但是您的数据可能具有更多列,并且每个条目的值都添加到该数据中.一次要传输的数据很多,而且速度很慢.如果您对它进行分页,则只需一次发送一次,这样会更快.
You should probably use the built in paging features of the GridView class (see this example[^])

That''s a lot of data for a web page, think about it:
Let''s assume you only have one column, each entry empty, and the encoding is UTF-8
The GridView will generate a table, each row needs "<tr>" and "</tr>" (9 bytes), and each item needs "<td>" and "</td>" (9 bytes), so:
20000 * (9 bytes per row + 1 item per row * 9 bytes per item) = 360,000 bytes, just for the markup with one column. But your data probably has more columns, and the values of your entries each add to that data. That''s a lot of data to transfer all at once, and it will be slow. If you page it, you only have to send them a little at a time, and it will be much faster.


WPF中有此代码,但是您应该能够翻译它没有大问题就可以传到Silverlight:
http://bea.stollnitz.com/blog/?p=344 [
There is code for this in WPF, you should however be able to translated it to Silverlight without big issues:
http://bea.stollnitz.com/blog/?p=344[^]


最好的选择是分页仅在结果页面快速加载时才加载最少页面记录,而忽略大量数据.
the best option is paging which loads minimum pages records only as a result pages load fast, it ignore large numbers of data.


这篇关于当数据源有2万行数据时,显示速度太慢了?如何提高显示速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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