Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys,

i have two aspx page. i want to pass a arraylist between two aspx page.
how can i pass arraylist using session?

pls help me...
thanks
Posted
Comments
CodingLover 20-Sep-11 0:34am    
How many items you have in the array list?
Prerak Patel 20-Sep-11 0:36am    
Any efforts?

you can keep arraylist object in session. and casting it back to original form.

put object in session.
C#
Session["Arr"] = objArrayList;


get it back to arraylist
C#
objArrayList =(ArrayList) Session["Arr"];
 
Share this answer
 
Comments
Member 8214635 20-Sep-11 1:47am    
thanks for help me... its one of the best answer
use cache...

1.aspx
ArrayList arr = new ArrayList();
arr.Insert(0, "file1");
arr.Insert(1, "file2");
arr.Insert(2, "file3");
Cache["test"] = arr;
arr = null;
Response.Redirect("2.aspx");

2.aspx
ArrayList ary = new ArrayList();
ary.Add(Cache["test"]);
Cache.Remove("test");

another way

1.aspx
ArrayList arr = new ArrayList();
arr.Add("file1");
arr.Add("file2");
arr.Add("file3");
string arry = String.Join(",", ((string[])arr.ToArray(typeof(String))));
Response.Redirect("1.aspx?file=" + arry);

2.aspx
string[] files = Request["file"].ToString().Split(',');
ArrayList arry = new ArrayList();
foreach (string file in files)
{
  arry.Add(file);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900