As stated in all posts, you can do some form of compression in multiple ways, you can implement it yourself or buy a viewstate compressor, but that won t help you too much. What might be interesting is the amount of compression you should expect. Take a look at: RadCompression to gets some info on compression rates, and performance improvements that are generally the same for all choices (free/paid).
我认为,这一比率并不令人满意,你应寻找办法解决你的问题。
Now, if I understand correctly you want to edit a grid row in a form on the same page. From the comments, you are using an update panel, and by the behavior described you have both your grid and edit form in an update panel.
If your page has only the grid and edit form, having them in an update panel won t help at all.
I ve made a small example for test purpose and I had a 10 rows grid with 5 columns and an edit form for the 5 fields on the same page.
My observations are:
- Having a grid with no style got me a 1500 char viewstate that amounts to 2KB. Adding styling would get you to a lot more data in viewstate, you can check any paid grid control examples and see that the amount of uncompressed viewstate goes on and on for hundreds of rows.
- Postbacking the hole page (no update panel) on grid selected item made a request of 3KB and got a response of 6KB
- Postbacking using an update panel that surrounds the grid and edit form made a request of 3KB and got a response of aprox 6KB. Almost no change in content size.
这是因为,利用更新小组,基本上意味着你不会更新整个网页,而只是你更新的Ppanel + 视带内的区域。 因此,如果更新小组包围了你的所有网页,那就赢得了你们的帮助,而且说它是不公平的。
Now, asp.net web forms has it s strengths but my opinion is that nobody likes asp.net web forms anymore, especially when having asp.net mvc / wcf / jquery at hand. Your question proves one of the limitations of asp.net web forms when used as originally intended.
My general solution for your problem would be:
- Use html only controls for data display (your grid should be a jquery/extjs plugin that displays json data that you get from an WCF ajax enabled web service). Getting rid of the asp grid will help you lower viewstate to almost nothing and make your page source readable.
- Make a WCF Ajax Web Service and exchange json in the client <-> wcf relation (examples of methods to use are: getgriddata, addnewrow, deleterow, editrow). Having these methods in place means that you won t have to fully postback at all, and that will make your page even nicer and more responsive. Also I would try not to use any code in page events.
- Call your web service using jquery or other javascript framework that you prefer; making sure you do not use the dreadful asp:ScriptManager will help you get rid of multiple calls to /ScriptResource.axd? and some odd looking in source javascript that does some wiring.