C# - Using a copy of Session-stored variables instead of reference

Posted by Nir on Stack Overflow See other posts from Stack Overflow or by Nir
Published on 2010-03-31T07:59:36Z Indexed on 2010/03/31 8:03 UTC
Read the original article Hit count: 553

Filed under:
|
|

I have an asp:ImageButton with OnClick="Btn_OnClick".
In Btn_OnClick I have this line:

DataTable dtTable = (DataTable)Session["someSessionKey"]

and dtTable is altered in the function.

I've noticed that if the button's clicked more than once, the dtTable I take from the session contains the altered table, probably meaning dtTable is not a copy but a reference of the session variable.

How can I alter a copy of Session["someSessionKey"], and not the actual value?
Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about session-variables