I have the following issue. I request you to please post your suggestions.
Problem:
1. I have stored the result of DB operation in a DataTable in a Session variable.
2. Created a new DataTable variable say ‘X’ and assigend the DataTable stored in the Session variable.
3. Performed few operations on the newly created DataTable variable ‘X’.
4. Now, when I browse the session variable, the data is changed along with the changes done to ‘X’.
I don’t understand why the DataTable has changed in the Session variable as the operations were performed only on the newly created DataTable ‘X’.
Your help is greatly appreciated,
Vinay
You are not creating a new DataTable – your variable X is just referencing the same DataTable that is stored in session.
If you want a new DataTable with the same structure and data use the
DataTable.Copymethod.