Thursday, March 29, 2012

Pass Object from one page to another

Hi, I have one page that has several methods that populate an ArrayList with data. I want to be able to pass this populated ArrayList to another page on the site. Is there any way that this can be done? I know values can be passed using the QueryString, but I need the whole ArrayList object to be passed.

Any help would be greatly appreciated.
Thanks

You can store it in a session variable:http://msdn2.microsoft.com/en-us/library/ms178581.aspx

From the page:

By default, session variables can be any valid .NET type. For example, the following code example stores anArrayListof values in a session variable named "StockPicks." Note that the valuereturned by the "StockPicks" session variable must be cast as theappropriate type upon retrieval from theSessionStateItemCollection.


1) You can keep the arraylist in the session object and can access the session object into another page.

2) You can make serializable class file and make the public object. By using context handler you can access the public object into another page.

Regards,

Suhas


Suhas.Chitade:

2) You can make serializable class file and make the public object. By using context handler you can access the public object into another page.

I've never tried this approach before. Would it mean that the same object is available to all users? Also, how long would the object persist?

0 comments:

Post a Comment