vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Tuesday, May 29, 2012

Refersh gridview for an every 10 second in asp.net


Introduction:

Here this article discuss about to refresh the grid view content on every 10 seconds.
This process accomplish by using JavaScript, Here we use the grid view inside the update panel so refresh occurs by asynchronously.
By using JavaScript, we call the button event for an every 10 second the data have been checking and refresh for an every 10 second.
In that button event you can write the code to bind the value in gridview.

Javascript Code:
<script type="text/javascript" language="javascript">
  Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(refreshClick);
  function refreshClick(sender, args) {
    button = $get("<%= buttonUpdate.ClientID %>");
    setTimeout(function() { button.click(); }, 0000);
  }
</script>

<asp:UpdatePanel ID="updateGrid" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:GridView ID="gridAutoUpdate" runat="server">
                </asp:GridView>
                <asp:Button ID="buttonUpdate" runat="server" Style="display: none" OnClick="buttonUpdate_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>

I hope you like this ..happy coding

0 comments:

Post a Comment