I checked, it is not null.
I have added more code below, on how i insert and then retrieve frm the
cache. The error is not in the inserting but in the retrieving frm the cache.
I insert into the cache:
Eg. i = 1.
if (Cache["testQuestion"+ i] == null)
{
Cache.Insert("testQuestion"+ i, ds.Tables)
}
else
lbl2.Text += "CACHE IS NOT NULL";
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();
}
I get the error: "Specified cast is not valid". TIA.