Click here to Skip to main content
15,937,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to implement Real-time loading data to the grid view with a silent refresh in ASP.Net. For this stuff, I tried below code.

What I have tried:

Default.aspx page

<script type="text/javascript">

        function EndGetData(arg) {
            document.getElementById("divScroll").innerHTML = arg;
        setTimeout("<%=CallbackRef %>", 100)

    <div id="divScroll">
        <asp:GridView ID="Grid" BorderColor="Turquoise" runat="server">

Default.aspx.cs Page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Default3 : System.Web.UI.Page,ICallbackEventHandler

    public string CallbackRef;
    public string _Callback;

    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsCallback)
            CallbackRef = ClientScript.GetCallbackEventReference(this, "'bindgrid'", "EndGetData", "'asyncgrid'", false);

    public void GetAuditData()
        DataTable dt = new DataTable();
        DataRow r = dt.NewRow();
        r[0] = "1";
        r[1] = "ABCD";
        DataRow r1 = dt.NewRow();
        r1[0] = "2";
        r1[1] = "XYZD";
        DataRow r2 = dt.NewRow();
        r2[0] = "3";
        r2[1] = "123D";


        Grid.DataSource = dt;

    public string GetCallbackResult()
        return _Callback;

    public void RaiseCallbackEvent(string eventArgument)//This function aceepts only one argument: That too only String Argument:
        using (System.IO.StringWriter sw = new System.IO.StringWriter())
            Grid.RenderControl(new HtmlTextWriter(sw));
            _Callback = sw.ToString();


Can you please suggest us or give me an example of code to do like
Updated 12-Mar-18 2:05am

1 solution

Simplest way of doing this is to put your gridview in an asp:UpdatePanel and use a asp:Timer

Tutorial: How to refresh an UpdatePanel control at a timed interval[^]
Share this answer
Bojjaiah 12-Mar-18 8:25am    
Nice answer. Do we have an example for gridview same as time ticker with the label.
Bojjaiah 12-Mar-18 8:42am    
I will get back after I tried. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900