Passing Array between pages

G

Guest

Hi,

How to pass the array or arraylist(dataset or any other object in fact) from
one page to another.
I am using the one page to display 10 records and another page to display
and modify the selected record. I want to pass the values of selected record
from one page to another. Can someone help me to do that?

Thanks in advance.
K_
 
G

Guest

On the page where you get your data, do this:

ArrayList myData = new ArrayList();
myData.Add("hello world");

Session["MyData"] = myData; //Add the data to session.

On subsequent pages when you need the data, do this:

ArrayList myDataRetrieved = (ArrayList)Session["MyData"];
 
G

Guest

Thanks a lot. That helped me a lot.
Can the custom objects be stored in session in similar way? I mean instead
of arraylist if I have a class called "Animals" and dog is the object, can I
pass this object between pages?

K_
 
G

Guest

Sure, you can store any object in session state, with one caveat: If you use
out of process session state, your object must be serializable. If you're
just using the standard in process session state, you don't have to worry
about it.



Paraki said:
Thanks a lot. That helped me a lot.
Can the custom objects be stored in session in similar way? I mean instead
of arraylist if I have a class called "Animals" and dog is the object, can I
pass this object between pages?

K_


Andy Luksic said:
On the page where you get your data, do this:

ArrayList myData = new ArrayList();
myData.Add("hello world");

Session["MyData"] = myData; //Add the data to session.

On subsequent pages when you need the data, do this:

ArrayList myDataRetrieved = (ArrayList)Session["MyData"];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top