Telerik UI for ASP.NET AJAX

Typically RadGrid stores in the ViewState only items/controls collections. However, sometimes the page ViewState can grow too big and might significantly increase the page download time.

You can control this behavior by setting the EnableViewState property of RadGrid to false if you do not wish the data for the controls in the grid to to be persisted in the ViewState. This means that the control will need to be rebound on every request: either by firing the NeedDataSource event or by going through an ASP.NET 2.x/3.x data source control.


When you set the EnableViewState property of RadGrid to False, the only supported way for binding is to use Advanced DataBinding (using NeedDataSource event or Declarative DataSources).

Although simple DataBinding is not supported when ViewState is disabled, there is a work-around that could be used in some cases. You need to call DataBind() method on the Grid instance on Page_Load event when the Page is initially loaded and on Page_Init event on any subsequent postback.

When having EnableViewState set to false, RadGrid will use the control state of the host Page to store only the absolutely necessary bits of data that preserve the current paging, sorting, and filtering state.

Some operations in Telerik RadGrid like data extraction through the ExtractValuesFromItem method, grouping, hierarchical views expand/collapse, custom edit forms (WebUserControl and FormTemplate) require that the EnableViewState is set to true. If no data is persisted for items in Telerik RadGrid (EnableViewState=false), then the state of items is lost after postback. Generally, data-source persistence optimization should be used if the small size/speed of a Page, showing RadGrid, is crucial for the application. If ViewState optimization is enabled, RadGrid will fire NeedDataSource and will bind after each post back to restore its items. RadGrid and its TableView manage the state of the following features while the EnableViewState property is set to False:

  • Indexes of selected items. Because of design limitations RadGrid only persists the selected items on the first postback. Any subsequent postbacks will clear the SelectedIndexes collection and thus will deselect the items. Possible work-around is to call the saveClientState() function of RadGrid which will save the selected items in the client-state of the control. The same rule applies for selected cells.

  • Indexes of edited items

  • Sort expressions

  • Style properties (but not if any style is applied on a single cell or row in ItemDataBound event)

  • Columns order and other column properties

  • All settings concerning hierarchy structure (but not the expanded state of the items)

  • Filter expressions(but not the filter value in the input control)

  • Current page index and the page size

RadGrid does NOT manage the state for the following features when its EnableViewState property is set to false:

  • Custom edit forms (user control or form template)

  • Value of the filter input control, however, the filter expression is persisted and so the filtered results.

  • GroupByExpressions are not persisted on Rebind and postback.

  • Expanded state of items in hierarchy. This basically means that you could not use more than one level of hierarchy, unlesss you save the expanded settings manually.

If you would like to retain the expanded state of items or server-side selection with ViewState disabled, you may consider using the approach depicted in this code library entry (applicable for explicit rebinds or ViewState switched off) or this knowledge base article . An alternative solution would be to turn on the ViewState of the grid and optimize its performance by using RadCompression and its page adapters as explained in this article.

See Also