1

I have a listbox that is getting data from the database . My problem is that i want to refresh that list box on every 3 seconds for example or some n seconds. Is this possible in ASP.Net can i update listbox on time without refreshing whole page? and if it is possible how can i do it?

Ok i did research about the updatepanel but i have problem making datasource of listbox and listbox refresh .

Thanks.

Vuk Vasić
  • 1,398
  • 10
  • 27
  • 2
    Research the use of a timer inside an updatepanel – Jack Pettinger Apr 05 '13 at 20:59
  • and here's the link: [Tutorial: How to refresh an UpdatePanel control at a timed interval](http://msdn.microsoft.com/en-us/library/cc295400(v=expression.40).aspx) – Tim Schmelter Apr 05 '13 at 21:01
  • You could use a timer coupled with an ajax call. See this similar question: http://stackoverflow.com/q/4542863 . – PHeiberg Apr 05 '13 at 21:02
  • Tim thanks for link but how can i refresh listbox with data source? i don't see example here – Vuk Vasić Apr 05 '13 at 21:08
  • I tried with dataSource.update() option and i setted the UpdateCommand to same as the initialization one. And then referenced data source of new – Vuk Vasić Apr 05 '13 at 21:36

1 Answers1

1

I think $.ajax should works great to you along with JavaScript setInterval like:

<script>
YourMethodName();

function YourMethodName()
{
  //bind your listbox using $.ajax
  setInterval(YourMethodName, 3000);
}
</script>

If you nee help how to bind listbox using jQuery then http://www.dotnetcurry.com/ShowArticle.aspx?ID=454 may help you.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Ken Clark
  • 2,500
  • 15
  • 15