PassionateDeveloper
PassionateDeveloper

Reputation: 15138

How to update every second from db?

I have to build a site like an auction-site:

I Have a detail page from items where a countdown should run down.

In this page nearly every second a update must be possible without a postback for the user:

What kind of timer should I use for the countdown? How can I update every second from DB? ( Ajax? ) How can I update the values / gridView?

Upvotes: 0

Views: 934

Answers (3)

James
James

Reputation: 82096

For the timer I would use Threading.Timer so this can count down uninterrupted in a separate thread. You could also use a TimerCallback delegate which would do the database processing. However, I would be wary about trying to query the database at such a rate.

I would advise you look at using Ajax Update Panel for updating the countdown section of the page alone so you don't have to refresh the entire page.

Upvotes: 0

Konamiman
Konamiman

Reputation: 50273

For the countdown, you can use the JavaScript timing events. To access the database, if you don't want postback then you indeed need to access the data service by using Ajax. To make things easier, I recommend that you take a look at any Javascript libary such as JQuery.

Upvotes: 0

RickNZ
RickNZ

Reputation: 18654

You can use an UpdatePanel with Ajax.

However, given the nature of "Internet weather," one second per update is pretty aggressive for that approach.

You might instead consider using Silverlight. You would have much more control that way, and could minimize the amount of data that needs to go over the wire. In fact, you could use long polling with raw TCP connections, to further increase scalability.

Upvotes: 4

Related Questions