简体   繁体   English

asp.net ObjectDataSource从缓存返回对象

[英]asp.net ObjectDataSource return object from cache

Is there any way to return object from Session when Select is called on ObjectDataSource? 在ObjectDataSource上调用Select时,有什么方法可以从Session返回对象吗? Specifically, I have Products object and saved in Session . 具体来说,我有Products对象,并保存在Session中 Now on another page I have ObjectDataSource which will call same bussiness object method to get Products object. 现在在另一页上,我有ObjectDataSource,它将调用相同的bussiness对象方法来获取Products对象。 Here I want to hook up any event like Selecting and I would like to return Products object from Session to Select method of ObjectDataSource. 在这里,我想连接诸如Selecting之类的任何事件,并希望将Session中的Products对象返回给ObjectDataSource的Select方法。

Is this possible? 这可能吗?

您必须将方法定义为静态方法,并使用HttpContext.Current.Session [“ products”]在方法内部访问Session。

ObjectDataSource has property EnableCaching property which can be set to true. ObjectDataSource具有属性EnableCaching属性,可以将其设置为true。 Enable Caching 启用缓存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM