custom paging a datagrid and caching

Posted on 2006-04-16
Last Modified: 2008-03-10

I use the term custom paging to refer to the process of retrieving database records one page at a time rather than all in one go.

I have seen caching implemented with datagrids that use default paging (get all the records in one go). Is there any point/benefit from implementing caching with custom paging? How would you implement caching with custom paging?

Thanks very much

Question by:andieje
    LVL 2

    Expert Comment

    It depends.

    The project that I'm working on at the moment can be connected to one of four different database technologies. Each have their pro's and con's but none have a consistent way to implement paging on the server side (ie the server only retrieves the rows needed for that page).

    So we've had to implement our paging on the client side (by client side I mean the webserver as opposed to the database server). In a lot of respects this is dumb since we are forcing our web server to retrieve heaps of records into memory (which almost defeats the purpose of paging in the first place) and then determine which 20 records should be displayed. But we need the paging for of a UI reason (limited space).

    Since it is likely that when the user see's a paged result set that they will navigate to at least one other page, we've implemented a client side cache. This saves us from making additional trips to the database to get the results of the other pages (since they were retrieved in the initial call).

    The caveat of caching is its not the real data. If the data in the database changes, the user won't know about it for as long as they are using their cache. So we have a timeout on our cache. If its not hit within say 30 seconds, then another trip to the database is performed etc. The time to invalidate your cache depends heavily on the likelihood of data underneath changing and how important it is to display that data to the user.

    Now to the second part of your question, how to implement the caching.

    In ASP.Net 2 it is very easy, if you can use one of the datasource controls since they have caching built in. Which version of ASP.Net are you using?

    Author Comment


    I am using 1.1 for this application (hence the datagrid)

    I do my paging using a stored procedure that only returns the relevant page of records at a time. I was wondering if there was any way to incorporate caching too or if that was overkill/pointless.

    LVL 2

    Accepted Solution

    I would argue that caching would probably not worth the effort but a lot does depend on how expensive your query is.

    Instead of caching the results from the database server, you could consider looking at caching the output from the webserver. ASP.Net 1/1.1 does support caching a page (or parts thereof) so that instead of execute code on the server, the cached page (or part of page) is returned instead. I know that you can set the cache to invalidate after a period of time, and that the cache can be made dependant on what form/querystring variables are present.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now