New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Saving the grid ViewState in Session

There are cases in which you may want to reduce the grid ViewState though you have enabled multiple server/client side features of the control (thus bypassing the EnableViewState = false choice with its limitations). In such situation to work properly with the NeedDataSource advanced data-binding or population through data source control, Telerik RadGrid's ViewState has to be turned on.

Still, a possible solution for ViewState reduction is to relocate it in a Session variable. The code below illustrates how to apply this technique under ASP.NET 3.x or 4.x:ASP.NET 3.x/4.x:

PageStatePersister _pers;
protected override PageStatePersister PageStatePersister
        if (_pers == null)
            _pers = new SessionPageStatePersister(this);
        return _pers;
Dim _pers As PageStatePersister
Protected Overrides ReadOnly Property PageStatePersister As PageStatePersister
        If _pers Is Nothing Then
            _pers = New SessionPageStatePersister(Me)
        End If
        Return _pers
    End Get
End Property

Further information on this subject can be found in the MSDN articles linked below:

See Also

In this article