当我在自定义分页和排序中启用缓存时,GridView 排序不起作用
我有一个 GridView,它使用存储过程进行自定义分页和排序。
它没问题并且工作正常(分页和排序),但问题是当我在 ObjectDataSource 中启用缓存时,例如:
EnableCaching="True"
它正确缓存用户访问的每个页面,但在这种情况下,当用户想要对其进行排序时会引发错误(虽然如果 EnableCaching ="False" 则工作正常:
The data source 'ObjectDataSource1' does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet.
当我启用缓存时,我应该做什么才能进行排序。
谢谢。
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 .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我们启用了缓存,那么当执行 select 方法时,会在触发 Selecting 事件之前访问缓存,并且如果我们正在搜索的数据在缓存中,
select 方法返回缓存的数据。
因此,如果我们在 Selecting 事件中对输入参数进行任何预处理(例如:排序),则缓存不起作用,因为创建的缓存键仅取决于选择参数(及其值)和分页值(因为缓存与寻呼)。另请记住,如果我们有排序参数,缓存将不起作用。
点击此处了解更多信息
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
这篇文章怎么样——
我从以下两个网址获得了线索:
在这两个中例如,他们实现了一个通用排序例程,用于处理 ODS(对象数据源)的排序,这样我们就可以设置 ODS 缓存属性:
有专家意见吗?
PS:为了提高性能,我在 ODS 以及使用该 ODS 的 GridView 中禁用了 Viewstate,并在 ODS 中启用了缓存。
How about this post -
I got the lead from the following two URLs:
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:
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.
这是我的评论:
优化分页和排序使用 EnableCaching = true 的 ObjectDataSource 进行排序
Here's my review:
Optimize Pagination & Sorting with ObjectDataSource having EnableCaching = true