you can just put the DataSet object in a Session object. You do:
private DataSet myDataSet=null;
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
myDataSet=QueryDatabase(); //method to query database to populate
DataSet
Session["MyData"]=myDataSet;
}
else
{
myDataSet=(DataSet)Session["MyData"];
if (myDataSet==null) //Session may become expired
{
myDataSet=QueryDatabase(); //re-query database when Session
object is gone
}
}
//Do sothing with the data here
}
Of course, you will take it into account that how much data populated into
the DataSet: you do not want to retrieve tens of thousands of records into a
DataSet and then leave them in server's memory.
Dennis said:
I was wondering...Is there a way that a DataSet can be kept available
throughout an entire session. I don't want to keep having to re-query the
database for the same data. If it is possible can someone point me in the
right direction? Thanks in advance!