[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Looping through and displaying records

Posted on 2011-10-16
Medium Priority
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
  • 2
LVL 16

Expert Comment

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

Say for example:

foreach(race r in races)
    //Display r


Accepted Solution

jagrut_patel earned 2000 total points
ID: 36977976
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

dparden earned 0 total points
ID: 36989610
What I had to do was us a FormView to handle the paging through the records.  Thanks for the help.

Author Closing Comment

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

834 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