I'm working with a webform that has a GridView. It has 5 columns and it receives about 2700 records from the web service feeding it. I'm paginating the GridView to 10 records. Is it possible to somehow store GridView data locally to improve pagination, sorting, editing, deleting, etc... data in the GridView? I thought I could achieve this by using ViewState and serializing and storing the data into a ViewState entry, and when DataBinding, simply calling and manipulating the already "local" data, but I'm suspecting all calls are sending the whole ViewState back to the server and everything is getting process at the server, and then being returned back to the page...
If at all possible, I appreciate any help.
1 Replies - 2841 Views - Last Post: 06 August 2013 - 05:20 AM
Replies To: Way to store large GridView data locally to improve GridView Functions
Re: Way to store large GridView data locally to improve GridView Functions
Posted 06 August 2013 - 05:20 AM
The whole point of ViewState is so that ASP.NET can restore the state of controls after a postback to the server. By placing more data into the ViewState you are actually making your application perform even slower since now the application is transporting all of that additional data on each call to the server on top of all of the data it has stored to maintain the state of the application. I'm not sure how your web service works, but ideally you should be able to send some parameters to it indicating how you want to order the data, the page index of the data, and the number of items to return. This way you are only pulling back the exact items you need rather than pulling back 2700 items on each call to the service and then filtering that for the 10 (or however many) items that you need. You could possible look at pulling back all of the items putting them in a DataTable that is stored in Session. Then on each GridView event you'd just need to make sure that the session value still has data in it, if it does use that to perform your action, if not then go and reload the data from the web service. Of course trying to store too much data in the web server's memory can also lead to performance problems.
Page 1 of 1