|
Subject:
|
Datacache Problem
|
|
Posted By:
|
monika.vasvani
|
Post Date:
|
9/22/2006 6:22:47 AM
|
HI Every1
I have two questions.
!st one is: I am using dataset and fill this dataset in ISPOSTBACK event.On button click event,I want to bind datagrid with this dataset but when i click on this button,data is lost.Is it possible? I declared dataset as public.
2nd one is:How to use datacache in appliction?I want to fill dataset in global.asax page in application_start event.I want to store this dataset into datacache?how can i do this?Pls if u have any ans,pls reply me.
Thanxs monika.
|
|
Reply By:
|
mike_remember
|
Reply Date:
|
9/26/2006 10:14:56 AM
|
Hi Monika
Values in the dataset will be lost once the page is submitted, if you want to preserve it, you can store the datset in a viewstate and then retrieve it, eg as below:
DataSet ds = new DataSet();
//First store in viewstate ViewState["ds"] = ds;
//then case back to dataset ds = (DataSet) ViewState["ds"];
//for testing you can display the row count Response.Write( ds.Tables[0].Rows.Count );
Regading caching, its simple as below: Cache["ds"] = ds;
Regards Mike
|