I want to know how to declare arraylist in one page and also i want to know how to retrieve that data's from the array list from one page to another page.
Thanks in advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gaurish KumarPosted Jan 20, 2010, 11:42 PM
You can't directly pass arraylist to another page.
but you can do this by using the session object. store whole array in session object and access that arraylist from session object in another
page. like that
ArrayList myArray = new ArrayList();
myArray .Add("hello world");
Session["Data"] = myArray ; //Add the data to session.
On subsequent pages when you need the data, do this:
ArrayList retrievedData (ArrayList)Session["Data"];
Hope it's help you.
Raunak JhawarPosted Jan 20, 2010, 11:37 PM
A similar post was answered by Nikhil and myself.
You should instantiate an object of form2 on form1
Pass relevant objects as deemwed necessary and call the parameterized constructor of form2 on form2.cs