There's an easy way to shrink all your viewstate.
Step 1. Create a new class that looks like this:
Imports System
Imports System.Web.UI
Public Class SessionPageStateAdapter
Inherits System.Web.UI.Adapters.PageAdapter
Public Overrides Function GetStatePersister() As System.Web.UI.PageStatePersister
Return New SessionPageStatePersister(Page)
End Function
End Class
Step 2. Add an App_Browsers
folder to your project.
Step 3. In your new App_Browsers
folder, add a new default.browser
file that looks like this.
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.Page" adapterType="[YourNamespaceGoesHere].SessionPageStateAdapter" />
</controlAdapters>
</browser>
</browsers>
When you run your pages now, you should find your viewstate size has dropped to a few bytes. The SessionPageStateAdapter class intercepts viewstate before it gets served to the browser and holds it in on the server in Session state. The bit of viewstate that still gets sent to the client is just an identifier that is used to reconstitute the original viewstate when the page gets posted back to the server.