Sign in | Join
Last post 03-02-2006 4:27 AM by StrongTypes. 1 replies.
Sort Posts: Oldest to newest Newest to oldest
I want to save an object, and make it available over several pages. So far it seems the best way for me to do this is to use sessions. However I can't find a way to store an object for the duration of a session. Below is some of the code
Fragment of Method 1 SearchResultCollection ownerResults = Code to return SearchResultCollection Session["ownerResults"] = ownerResults; Fragment of Method 2 SearchResultCollection ownerResults = Session["ownerResults"]; However, I get the following error. Error 1 Cannot implicitly convert type 'object' to 'System.DirectoryServices.SearchResultCollection'. An explicit conversion exists (are you missing a cast?) My question is, how can I store an object, to be used by the same page, or different page in the same session? Thanks Ben
SearchResultCollection ownerResults = Code to return SearchResultCollection
Session["ownerResults"] = ownerResults;
Fragment of Method 2
SearchResultCollection ownerResults = Session["ownerResults"];
However, I get the following error.
Error 1 Cannot implicitly convert type 'object' to 'System.DirectoryServices.SearchResultCollection'. An explicit conversion exists (are you missing a cast?)
My question is, how can I store an object, to be used by the same page, or different page in the same session?
Thanks
Ben
You'll need to do something like this:
SearchResultCollection ownerResults = Session["ownerResults"] as SearchResultCollection;
if (ownerResults != null){ // Code here}
HTH,Ryan