RadGrid for ASP.NET AJAX

RadControls for ASP.NET AJAX

Typically RadGrid stores in ViewState only items/controls collection, not data source data. Sometimes though 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 to false if you do not wish the data for the controls in the grid to to be persisted in the view state. 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 having EnableViewState set to false, RadGrid will use the page control state to store only the absolutely necessary bits of data that preserve the current paging, sorting, and grouping state.

Note

Note that disabling view state datasource storage by setting EnableViewState to false will work both for the ASP.NET 2.x or 3.x build of RadGrid.

Some operations in Telerik RadGrid like data extraction through the ExtractValuesFromItem method, grouping, hierarchical views expand/collapse, automatic data source operations, custom edit forms (WebUserControl and FormTemplate) or filtering 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 Telerik RadGrid, is crucial for the application. If view state optimization is enabled, RadGrid will fire NeedDataSource and will bind after each post back to restore its items.RadGrid and its table-views manage the state of the following features while its EnableViewState property is set to false:

· Indexes of selected items (Telerik RadGrid support this automatically only for server-side selection)

· Indexes of edited items

· Group-by expressions and settings (but not the expanded state of the grouped 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)

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)

· filtering

· grouping

· expanded state of items in hierarchy

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