Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Grid empty after binding to dataset retrieved from Cache

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
US
Hi,
I am binding DataGrid to a dataview from a DataTable retrieved from Cache. When cache is empty and dataset is retrieved for the first time from DB everything is fine and the datagrid shows.
Now when I get the dataset from cache and bind it to datagrid, grid show up empty! I iterated through data set and it looks like the data is there after I retrieve it from cache. Thanks for any tips:
Here is code:

public static DataSet GetCatalog()
{
DataSet Catalog=null;

if(HttpContext.Current.Cache["Catalog"]!=null)
{
Catalog = (DataSet)HttpRuntime.Cache["Catalog"];
}
else
{
//get from database and put in cache
Catalog = ZoyaModaDP.LoadCatalog();
//store in Cache for an hour
HttpRuntime.Cache.Insert("Catalog",Catalog,null,DateTime.Now.AddMinutes(60),TimeSpan.Zero);

}

//test
DataView dv=Catalog.Tables["Category"].DefaultView;
foreach (DataRow row in dv.Table.Rows)
{
string test = row["Name"].ToString();
string test2 = test;
}
return Catalog;

}

Here is code from aspx page:

DataSet Catalog = GetCatalog();
CategoryDataGrid.DataSource = Catalog.Tables["Category"].DefaultView;
CategoryDataGrid.DataBind();
 
DUH! sorry.. looked at it too quickly

the only thing I see is that you are mixing namespaces for cache. you are using both HttpRuntime and HTTPCurrent. Try sticking with one, HTTPCurrent.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top