Ahh, that is the problem then. ASP.NET pages are created when a page is
requested and are thrown out when the request is complete, rather than have a
single instance stay in memory for all requests.
In order to save the dataset, you will need to cache it in order to maintain
it between requests.
The big question is do you want this dataset accessible by all callers to
the page, or a separate instance for each individual user?
If the first, the quickest way to do it is with the Application state, if
the second, the Session state is your best bet.
Inside of your Form_Load event handler, after you have created your dataset
and set it equal to your public variable, you would want to do the following:
Session["mydataset")=ds;
Where mydataset is a name you are giving to the dataset within the Session
state and ds is a reference to it.
Just for note, if you want to use the Application state, simply replace
Session with Application.
That stores the dataset, now, in order to use it you need to retrieve it
from the store, to do so, you would simply do (inside of your Form_Load, but
when a postback:
ds = (DataSet)Session["mydataset"];
Again where ds is the name of the reference you want to the dataset and
mydataset is the same name you gave above.
Brendan
"Steven Blair" wrote:
Yeah my DataSet is initially populated inside
if (!IsPostBack)
{
//Fill DataSet
}
I only ever want it filled once, thats why its in here.
I am using a Wizard component so Page_Load gets called each time user
changes a page.
Surely only one instance of MyForm class exists, and after every call of
Page_Load, does this mean a new instance exists?
I tried declaring my DataSet as static, and that allows me to access the
data, but to me that makes no sense.
Can you explain in some detail whats happening here?
*** Sent via Developersdex http://www.developersdex.com ***