Click here to Skip to main content
16,004,678 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to store datatable or dataset in session..and what are the advantages and limitations on that 


What I have tried:

I want to pass 15 records from one page to another,it's a right way to use session with datatable??
Posted
Updated 26-Apr-17 3:50am

Try this:-

Session["xyz"]=ds;


Or You can refer following link :

store data set in session[^]
 
Share this answer
 
v2
To use session brings a few problems:
1. Data stored on session gone when session is out (user went to drink a coffee)
2. Session data uses the memory of the host computer, so big/numerous sessions can cause performance problems if hardware is not scaling with...

It is absolutely unclear from where those 15 records came, but it was better to pass only single parameters between pages and not junk of data...
For instance when you open a list of books of an author, where the author picked from a list, you only pass the author id to the next page and it is the responsibility of that page to load the list of relevant books...
 
Share this answer
 
It is not the good practice to store a list of records in session.

In the first page from where you get the data?
Same way you can retrieve the list of records in 2nd page by passing the single parameter in 2nd page by the help of session.

let say:
You have a list of records of one ID in first page. You can pass that ID as parameter in 2nd page by the help of session.

Ex:

Firstpage:

Session["Keyname"]="YourValue";


2nd Page:

You can retrieve the list of records in of that session key.

---------------------
As per the question if you want to set the ds to session then here is the code.

Set: In first page
DataSet ds=new DataSet();

Session["KeyName"]= ds;

Get in 2nd page:

DataSet ds= (DataSet) Session["KeyName"];

------------
 
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