Caching in for dynamic data in gridview

I've a webpage with GridView which is populated from database table. User can click on column names which gives an option of distinct values through which user can select the filter.. Just like how we have AutoFilter option in Excel. It is building dynamic queries based on user filter selection and populating the Gridview.

I've to use Caching mechanism for this webpage as the data would change once in a day.

I tried using <%@ OutputCache Duration=3600 VaryByParam="None" %> when I select the filter it populates for the first time. But when I select for further filter, IE gives error 'Internet Explorer cannot display the webpage'

I'm not sure whether caching is feasible for this webpage as queries are dynamic. Please let me know is there any other mechanism to achieve this or to enhance the website performance.


Output caching is not what you want in this situation, it caches the HTML output of the page so ASP.NET doesn't have to regenerate it.

It sounds like you're looking for the built in Cache class that can hold arbitrary objects for given amounts of time.

Depending on how fast your queries are you could either cache the whole data set and then filter it with LINQ, or you could store the filtered versions you got from SQL Server.

I use it something like this:

var cachedList = HttpContext.Current.Cache["cacheKey"];
if (cachedList == null)
    var db = new YourDataContext();

    //get your data from the db here somehow
    cachedList = db.table
        .Where(x => true)

return (List<YourDataType>)cachedList;

Need Your Help

Checking if an iterator is valid

c++ stl iterator dereference

Is there any way to check if an iterator (whether it is from a vector, a list, a deque...) is (still) dereferencable, i.e. has not been invalidated?

Comments Listview in Android

android listview android-listview

I have an Activity which contains different items, one of those item is ListView.