Sunday, May 27, 2012

How+to+pass+array+values+in+query+string

http://forums.asp.net/t/1370240.aspx/1?How+to+pass+array+values+in+query+string 
 
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);
}

No comments:

Post a Comment

Blog Archive