Looping through and displaying records

Posted on 2011-10-16
Last Modified: 2013-12-16
I have a List<race> races that I pull from a DB when I open my aspx Page.  I want to be able to loop through races, displaying each individual race seperatly for a period of time before displaying th next race.  

How do I do this without having to read from the database each time?  I am familiar with Timer and getting the timer even to fire, but each time it fires, the page_load event is firing.  
Can I prevent this?  Is there a better way to have the records display one after the other without user intervention?
Question by:dparden
    LVL 16

    Expert Comment

    by:Easwaran Paramasivam
    Timer has Sleep Method where you can specify your delay.

    Say for example:

    foreach(race r in races)
        //Display r

    LVL 8

    Accepted Solution

    I think you cannot do this only with code-behind. The page will need to make explicit request for next race at regular intervals.

    1. Use Javascript timer to post request at regular intervals.
    2. When this timer tick make an AJAX request to fetch next race information. Pass some identity value of the current race so that on server you can determine then next race data to be soon.
    3. To prevent fetching race data repeatedly from database you can use Cache. When a request is first received check whether it is available in Cache if not then get it from the database, cache it and then send to the client. You can put a Dictionary<int, Race> data-structure in cache for storing race data. Here key value is the unique identification value of a race (A Primary Key).

    Assisted Solution

    What I had to do was us a FormView to handle the paging through the records.  Thanks for the help.

    Author Closing Comment

    FormView was the solution I needed.  The other answer given did point me in the right direction.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now