Looping through and displaying records

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?
dpardenAsked:
Who is Participating?
 
jagrut_patelCommented:
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).
0
 
Easwaran ParamasivamCommented:
Timer has Sleep Method where you can specify your delay.

Say for example:

foreach(race r in races)
{
    //Display r

    Thread.Sleep(interval);
}
0
 
dpardenAuthor Commented:
What I had to do was us a FormView to handle the paging through the records.  Thanks for the help.
0
 
dpardenAuthor Commented:
FormView was the solution I needed.  The other answer given did point me in the right direction.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.