Last post Jan 16, 2011 10:24 PM by decker dong - msft
Jan 13, 2011 10:56 PM|nmahesh567|LINK
Is there any way to return object from Session when Select is called on ObjectDataSource? Specifically, I have Products object and saved in
Session. Now on another page I have ObjectDataSource which will call same bussiness object method to get Products object. Here I want to hook up any event like Selecting and I would like to return Products object from Session to Select method
Is this possible?
Jan 13, 2011 11:27 PM|cyberbud|LINK
The only way to trick your objectdatasource I see so far in your case is to return the session object from your business object.
What I mean is if you have stored your datasource in your session then you can simply access that session object in your business object and return it if it consist of data.
To do so you may need to add reference to System.Web in your business service project. And access it as,
Jan 13, 2011 11:59 PM|PeteNet|LINK
Are you trying to avoid having the ODS re-create the object itself? If so, use the ObjectCreating event to assign from the Session (your thread title goes by cache though).
The documentation has the explanation along with an example: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.objectcreating.aspx
Jan 14, 2011 09:33 AM|nmahesh567|LINK
No, I do not want to cache Business object instance in session. I would like ObjectDataSource get
dataobject from Session.
ObjectDataSource is poiting to business object method and I do not want to refer ASP.NET's Session / Cache classes within Busines objects.
I would like to have ObjectDataSource point to business object but before calling business object's method, I want to check if data object is in Session (in web site code) and if so return from session and cancel business' method call.
Jan 14, 2011 09:42 AM|PeteNet|LINK
I do not want to refer ASP.NET's Session / Cache classes within Busines objects.
I would like to have ObjectDataSource point to business object but before calling business object's method
Use the ObjectCreating event. Read through the documentation I've posted.
Jan 14, 2011 10:55 AM|nmahesh567|LINK
That did not help as it is about caching Business object instance. As I said in previous post, I am nit looking to cache business object instead I am looking to cache Prdoucts object in session and return to ObjectDataSouce before calling business object's
select method if Products exist in session.
Jan 16, 2011 03:36 AM|cyberbud|LINK
Well nmahesh, I'm still gonna stick to my solution.
Another way would be to enable caching of your objectdatasource control. When you have enabled objectdatasource caching, object datasource control doesn't create a new instance of your business object and call the select method. Set your cache duration time
to the desired time.
But if you want to cache the data for multiple object datasource(which i think is your case) then you need to use session in your business object method.
Otherwise caching would do just fine and serve your purpose
Hope I've been helpful
Jan 16, 2011 10:24 PM|Decker Dong - MSFT|LINK
Session will be used as an identifier to mark what you have while viewing the whole page site.
I mean that you can just save something into session and take it out and make a cast conversion if necessary.
Anway, you can also use SessionParamter in <SelectParameter>, if you want.
See something like this: