Hi,
I agree to what Grant is saying. Please try this out.
if (Cache["testQuestion"+ i] == null)
{
Cache.Insert("testQuestion"+ i, ds.Tables[i]);
}
retrieve from the cache:
DataTable dt2 = (DataTable)Cache["testQuestion"+ (int)ViewState["QnNo"]];
if (dt2 != null)
{
dt2 = (DataTable)Cache["testQuestion"+ (int)ViewState["QnNo"]];
MyRepeater.DataSource = dt2;
MyRepeater.DataBind();
}
All i have done here is modified your original code little bit. And Please
be assured that it wont bother your logic of accessing exactly that number of
table in the original dataset that you have implemented by using "i". :)
Hoping a thanks as it is going to work out perfectly.
"Andrew" wrote:
I hope this doesn't sound too silly. I am trying to cache a datatSet. I have
written the code below.
I insert into the cache:
Eg. i = 1.
if (Cache["testQuestion"+ i] == null)
{
Cache.Insert("testQuestion"+ i, ds.Tables[i]);
}
retrieve from the cache:
DataSet ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]];
if (ds2 != null)
{
ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]];
MyRepeater.DataSource = ds.Tables[(int)ViewState["QnNo"]];
MyRepeater.DataBind();
}
Is there a problem there ?
TIA.