Skip to main content
A newer version of this page is available. .

GridViewSettings.EnableRowsCache Property

Gets or sets whether data caching is enabled.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v19.2.dll

Declaration

public bool EnableRowsCache { get; set; }

Property Value

Type Description
Boolean

true, to enable data caching; otherwise, false.

The default is false.

Remarks

The GridView extension is able to store its data (the data of the current grid page) in memory for quick access. This might help avoid repeated database calls when performing various operations that don’t require reloading data (e.g., rearranging or hiding columns). For instance, this can be useful when the GridView is used in Database Server Mode - to reduce the number of database calls. To enable data caching, set the EnableRowsCache option to true.

By default, row data caching is disabled within the GridView. It is recommended to leave the EnableRowsCache property disabled in the following cases:

  • The GridView displays real-time data.
  • The GridView is bound to data created at runtime (because calling the Bind method always reloads data from the server).
  • The GridView contains a BinaryImage column - a column whose MVCxGridViewColumn.ColumnType property is set to MVCxGridViewColumnType.BinaryImage (because preserving binary data in the row cache might dramatically increase the cache size and affect the application performance).

Note that the EnableRowsCache option must be disabled in the following cases:

Note

If you use custom objects that utilize a referenced association, the GridView tries to cache references too. The serialization of a custom object is performed by the ToString method and is performed smoothly. But the object deserialization (restoration from String to object) could be raised with an exception:

TypeConverter cannot convert from System.String.

One solution is to turn off the EnableRowsCache property. This solution is acceptable when the page doesn’t have several grids, and in most cases doesn’t affect page performance significantly.

However, you can implement a custom TypeConverter derived class that can convert from the String type correctly. To learn more, see the Code Central example: How to implement a custom TypeConverter class for an XPO object

See Also