Refresh asp.net panel content

Posted by Agasimani under ASP.NET on 10/19/2015 | Points: 10 | Views : 555 | Status : [Member] | Replies : 2
Hi frds,
how to refresh gridview or repeater contents every 10 seconds automatically without postback...?

Thanks




Responses

Posted by: Sheonarayan on: 10/19/2015 [Administrator] HonoraryPlatinum | Points: 25

Up
2
Down
You can use asp:Timer control and in OnTick event you can call a method that re-populates the GridView or Repeater control. Read more about timer at http://www.dotnetfunda.com/tutorials/ajax/timer.aspx.

Preferable approach

However, above is not preferable ways now, you can instead use javascript timer and call jquery get method to populate the data.

<script>

var count = 0;
function TestFunction() {
count++;

$.get(
"PopulateDataAgain.aspx",
{ ag: "2", bg: "6" },
function (data) {
$("#divResult").html(data);
});

t = setTimeout("TestFunction()", 10000);
}
</script>

Look at above code snippet, where we are calling PopulateDataAgain.aspx page after every 10000 milliseconds (10 seconds). This page will have the GridView or Repeater control and in page load, populate the data to the GridView or Repeater.

This should work.

In case you are looking to learn jQuery.get method read this http://techfunda.com/Howto/jquery/397/post-get-get-post-request-to-server and to understand JavaScript timer, read this http://techfunda.com/Howto/javascript/594/timer.

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Agasimani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Narenkumar851 on: 10/22/2015 [Member] Starter | Points: 25

Up
0
Down
set timer interval is 10 second
use ajax http://dotprogramming.blogspot.com/2013/04/how-to-change-data-without-postback.html

Agasimani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response