I am having a problem with session variables and arrays.
I am storing an array in a session variable in the first page.
Page 1
int [] p;
session["price"]=p;
In Page 2 I am trying to add the contents of another array into the same session variable.
Page 2
int [] q;
session["price"]=q;
The contents of q is overwriting the contents of p in the session variable price...I dont want this to happen.
Basically what I need is a single session variable in which I can store contents of different arrays simultaneously
Please help
Thanks
Satish.
Yes it will overwrite, because, a Session["Key"] can hold only one object value. Since you are assigning q to the same session. it will over write it. Instead you can take List<T> of int array and store the List<T> in the session.
HTH
0 comments:
Post a Comment