Can we store a dataset in a session? How?

Forums C#Can we store a dataset in a session? How?
Staff asked 3 years ago

Can we store a dataset in a session? How?

Yes, we can do this, the example is given below, if you like the answer give me an upvote😁

DataSet dset = new DataSet();
DataTable dTable = new DataTable();
DataColumn dCol = new DataColumn("name",typeof(string));

dTable.Columns.Add(dCol);
dTable.Rows.Add("Karan");
dset.Tables.Add(dTable);

Session.Add("My-demo-table", dset);
// and then whenever you need that Dataset just get it from Session.
DataSet Tissues = (DataSet)Session["My-demo-table"];

 

Karan Rajgor replied 3 years ago

Subscribe

Select Categories