Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
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!
Posted
Comments
lewax00 7-Aug-12 14:13pm    
Is it slow on the machine hosted the server (e.g. when you debug it locally), or just when someone loads it remotely? Because if it's the latter then there isn't much you can do, a lot of data being displayed means a lot of data has to be transferred, and that takes time based on your network connection.
PEIYANGXINQU 7-Aug-12 14:17pm    
Both, I think we can optimize this.
[no name] 7-Aug-12 14:22pm    
It's called paging. Besides that, no one is going to look at 20K rows of data. No reason at all to be doing that to begin with.

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.
 
Share this answer
 
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[^]
 
Share this answer
 
the best option is paging which loads minimum pages records only as a result pages load fast, it ignore large numbers of data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900