In my project everywhere I get data(ex.customers) in a datatable and for further use I store it in session as

Session.Add("DtTblName",dt_Cust);

And access through dt_Cust=(DataTable) Session["DtTblName"];

All is working fine, my concern is, Is it a right way to store heavy object like datatable store in session, to avoid database access?
What happen if little bit more website users will have their own sessions?

IF this way is correct tell me as, if not please suggest other way with little justification.

In my project everywhere I get data(ex.customers) in a datatable and for further use I store it in session as

Session.Add("DtTblName",dt_Cust);

And access through dt_Cust=(DataTable) Session["DtTblName"];

All is working fine, my concern is, Is it a right way to store heavy object like datatable store in session, to avoid database access?
What happen if little bit more website users will have their own sessions?

IF this way is correct tell me as, if not please suggest other way with little justification.

DataTable Tissues = new DataTable();

Tissues = dal.returnTissues("TestID", "TestValue");// returnTissues("","") sample function for adding values

Session.Add("Tissues", Tissues);

Retrive that datatable from session: DataTable Tissues = Session["Tissues"] as DataTable

or

DataTable Tissues = (DataTable)Session["Tissues"];

DataTable Tissues = new DataTable();

Tissues = dal.returnTissues("TestID", "TestValue");// returnTissues("","") sample function for adding values

Session.Add("Tissues", Tissues);

Retrive that datatable from session: DataTable Tissues = Session["Tissues"] as DataTable

or

DataTable Tissues = (DataTable)Session["Tissues"];

Hi crishlay, I think you have misunderstood my question!

I know how to store datatable in session and how to retrieve it from session again.

I asked, we use sessions to avoid DB transactions but it is a right way when website storing huge amount of data in session? (ex. datatable having 200 rows.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.