How To Cache Rows In DevExpress ASP.NET GridView

22 September 2009

ASPxGridViewSuite Check out this short article on how to use the row caching property of the ASPxGridView and an upcoming feature of the ASPxPivotGrid:

What is EnableRowsCache?

In general, this is a good feature because it’s helps your web application’s scalability. How?

By default, the ASPxGridView stores data in memory for quick access. This avoids repeated database calls when performing various operations that don't require reloading data (e.g. rearranging or hiding columns). Therefore, it increases your Web application’s scalability and the individual operations will be quicker because there's no database access happening in that particular cycle.

As a bonus for the inquisitive minds: The DevExpress ASP.NET controls store items in memory by using our own custom callback state. It’s similar to the Microsoft ViewState, except that the DevExpress CallbackState lives between callbacks and not postbacks. Want to learn more? Check out the “Speed up your page loads with a lighter ViewState” blog post.

When To Set It To False?

To disable data caching, set the EnableRowsCache option to false. This can be useful, for instance, when the ASPxGridView displays real-time data. It's also recommended that you disable this option when binding to data created at runtime, because calling the DataBind() method will always reload data from the server.

ASPxGridView's EnableRowsCache Property

Coming Soon To ASPxPivotGrid

The ASPxPivotGrid can have a large amount of data even between callbacks. For these scenarios, you may not want to store that info in memory. Now you have the option to disable row caching in the ASPxPivotGrid as well.

The ASP.NET team has just added the EnableRowsCaches feature to the ASPxPivotGrid. The option will be officially available in an upcoming major release.

DevExpress Platinum Sponsor at Microsoft PDC

13 comment(s)
Robert Beaubien

When you say the data is stored in memory, are you referring to on the server, or on the client?

22 September, 2009
Mehul Harry (DevExpress)

Hi Robert,

In between requests, the data is persisted on the client and loaded on the server during a request. There's a good article on it here: Understanding ASP.NET View State - http://j.mp/14gOsa

22 September, 2009
Servefault.com

Thank you for submitting this cool story - Trackback from Servefault.com

22 September, 2009
Ralph Jansen

I don't really understand how it works when you use lists. When you get a list of say 10 articles from you database. You say: aspxgrid.datasource = Listofarticles. After that you say databind();

Now everytime you get a postback, the list will get out of your db because this is done in the pageload.

Do I miss something here?

Thanks.

23 September, 2009
Claus Bogner

Yeah, awesome, can't wait for the coming to PivotGrid... :)

23 September, 2009
Mehul Harry (DevExpress)

Claus,

Thanks to your feedback which helped us add the feature to ASPxPivotGrid.

23 September, 2009
Mehul Harry (DevExpress)

Hi Ralph,

The EnableRowsCache is only needed to save the current page content. Therefore, if the request to the server is not instantiated by the ASPxGridView and there is no need to refetch data from the db server then the ASPxGridView will take this data from the cache.

So if the EnabledRowsCache is enabled and the page is refreshed then data will be pulled from cached. Unless, some specific action is set on the ASPxGridView like changing page, sorting, filtering, paging, grouping, etc...

I think that's what you meant by your question. If not then these links may help you as well:

community.devexpress.com/.../206576.aspx

www.devexpress.com/.../Q91024.aspx

23 September, 2009
DotNetBurner - ASP.net

DotNetBurner - burning hot .net content

23 September, 2009
The ASPx Blog - Mehul Harry's DevExpress Blog

The DevExpress ASP.NET pivot grid now supports row caching with the DXperience 2009 volume 3 release

30 December, 2009
Shaung Liu

So shouldn't ASPxGridViewExporter work with the cache turned on without doing a DataBind on the postback?  This doesn't seem to work but I may have something set incorrectly since I'm just evaluating the product.

Thanks.

13 July, 2010
Amin Abdul Rahman

Mehul,

Are you saying if I use Paging, this will be always a round trip request to database?

Thanks.

21 July, 2010
Mehul Harry (DevExpress)

Amin,

It depends on the DataSource you use. For example, with our ServerMode in XPODataSource or LinqServerModeDataSource then it will always cause a roundtrip to the DB.

This is fine for large DBs. In fact, you would rather do that then load everything up. Take a look at this video to see about Servermode:

community.devexpress.com/.../aspxgridview-screencast-enable-server-mode-using-linq.aspx

For sure though, the paging will use Callbacks.

Hope that helps.

21 July, 2010
Martin Desaulniers

Can wait for the Pivot new feature.

19 December, 2011

Please login or register to post comments.