Click here to Skip to main content
15,896,040 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.. Friends, I have a web application in which I am storing some value in
Session["dbValues"] but my problem is, I want to add some new data in this session without lost the old data.

For example I my Session["dbValues"] has value 1 then I want to add new value 2


Thanks & Regard
Parveen Rathi
Posted

Assuming you are using DataTable to hold the values, pleasee see the following solution :

C#
DataTable dt = Session["dbValues"] as DataTable;
DataRow dr = dt.NewRow();
// add data to the new row
// i.e. dr["name"]="something";

// add this row to DT now
dt.Rows.Add(dr);

// assign this modified Datatable back to Session
Session["dbValues"] = dt;


Similarly, You can type cast any object that you are holding in Session and manipulate the object and re-assign it to same session variable.
 
Share this answer
 
Hi ,
It depend on the data you want to store it on Session if it String you can use Append or you can use Array

Best Regards
M.Mitwalli
 
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