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

Optimize RadGrid ViewState usage

Updated on Oct 7, 2026

RadGrid stores item and control collections in ViewState. On pages with large grids or many controls, this state can increase the response size and page download time.

Set the EnableViewState property of RadGrid to False when the application can recreate the grid data and does not require the features that depend on item ViewState. The grid must then be rebound on each request through the NeedDataSource event or a declarative data source. See Programmatic data binding using the NeedDataSource event and Declarative data sources.

When EnableViewState is False, simple data binding is not supported as the normal binding approach. If you must use simple data binding, rebind the grid in Page_Load on the initial request and in Page_Init on subsequent postbacks, as shown below.

Rebind a simply bound grid

The following example disables ViewState and binds the grid on the appropriate page lifecycle events.

Rebind a RadGrid with EnableViewState disabled

ASP.NET
<asp:ScriptManager ID="ScriptManager1" runat="server" />

<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0"
    EnableViewState="False" GridLines="None">
</telerik:RadGrid>
<asp:Button Text="Postback" ID="Button1" runat="server" />
C#
using System;
using System.Collections.Generic;

public partial class Default_Cs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadGrid1.DataSource = MasterData();
            RadGrid1.DataBind();
        }
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            RadGrid1.DataSource = MasterData();
            RadGrid1.DataBind();
        }
    }

    private List<MasterItem> MasterData()
    {
        var masterItems = new List<MasterItem>();
        for (int index = 0; index < 6; index++)
        {
            masterItems.Add(new MasterItem(index, "Master_Value_" + index));
        }
        return masterItems;
    }
}

public class MasterItem
{
    public int MasterItemID { get; set; }
    public string MasterItemValue { get; set; }

    public MasterItem(int masterItemID, string masterItemValue)
    {
        MasterItemID = masterItemID;
        MasterItemValue = masterItemValue;
    }
}

When EnableViewState is False, RadGrid uses control state to retain the data needed for features such as paging, sorting, and filtering. The grid still needs to be rebound so that its items and controls are recreated after a postback.

Features preserved by RadGrid

Some RadGrid features remain available when EnableViewState is False. RadGrid and its table views manage the following state:

  • Selected item indexes. RadGrid persists selected items on the first postback, but later postbacks can clear the SelectedIndexes collection. You can use the saveClientState() client method to preserve selected items in client state. The same limitation applies to selected cells.
  • Edited item indexes.
  • Sort expressions.
  • Style properties, except styles applied to an individual cell or row in the ItemDataBound event.
  • Column order and other column properties.
  • Hierarchy settings, but not the expanded state of hierarchy items.
  • Filter expressions, but not the value in the filter input control.
  • Current page index and page size. In a custom-paging scenario, these values are available in the PreRender event.

Features not preserved by RadGrid

The following features require EnableViewState to be True or require additional state management:

  • Data extraction through the ExtractValuesFromItem method.
  • Grouping.
  • Hierarchical item expansion and collapse.
  • Custom edit forms that use a user control or form template.
  • The value in a filter input control. The filter expression is persisted, so the filtered result remains available.
  • GroupByExpressions after a rebind or postback.

With ViewState disabled, a hierarchy cannot reliably use more than one expanded level unless you save the expanded settings manually. To preserve expanded items or server-side selection, see Retain expanded and selected state in a hierarchy on rebind.

See Also