开发者

GridView sorting doesn't work when I Enable Caching in Custome Paging and sorting

开发者 https://www.devze.com 2022-12-14 20:52 出处:网络
I have a GridView that use a stored procedure for custom paging and sorting . It\'s OK and works fine (Both paging and sorting) , But the problem is when i Enable Cachingin ObjectDataSource like:

I have a GridView that use a stored procedure for custom paging and sorting .

It's OK and works fine (Both paging and sorting) , But the problem is when i Enable Caching in ObjectDataSource like :

 EnableCaching="True"

It properly cache every page that the user visit , But at this case when the user want to sort it raise an error(While that works fine if EnableCaching ="False" :

The data source 'ObjectDataSource1' does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and 开发者_高级运维DataSet.

what should i do in order sorting works when i Enable caching .

Thank you .


If we have caching enabled, when the select method is executed, the cache is accessed before firing the Selecting event and if the data we're searching is in the cache, the select method returns with the cached data.

So if we're doing any preprocessing (ex:sorting) of the input parameters in the Selecting event caching doesn't work because the cache key created depends only on the select parameters (and its values) and paging values (as caching works with paging). Also keep in mind that caching doesn't work if we have a sort parameter.

Click here to read more


How about this post -

http://forums.asp.net/p/1509071/3676014.aspx#3676014

I got the lead from the following two URLs:

http://www.codeproject.com/KB/aspnet/GridViewObjectDataSource.aspx http://forums.asp.net/t/1344883.aspx

In both these examples, they've implemented a generic sorting routine which handled the sorting of ODS (Obj Data Source) and with this we're able to set the ODS caching property:

EnableCaching="True"

Any expert opinions?

PS: To boost-up the performance I've the Viewstate disabled in both ODS as well as the GridView using that ODS and Caching on in ODS.


Here's my review:

Optimize Pagination & Sorting with ObjectDataSource having EnableCaching = true

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号