ASP.NET Timer Event

Posted by K Ratnajyothi on Stack Overflow See other posts from Stack Overflow or by K Ratnajyothi
Published on 2010-05-10T05:04:14Z Indexed on 2010/05/10 5:08 UTC
Read the original article Hit count: 539

Filed under:
|

protected void SubmitButtonClicked(object sender, EventArgs e) { System.Timers.Timer timer = new System.Timers.Timer(); --- --- //line 1 get_datasource();

String message = "submitted.";
       ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "popupAlert", "popupAlert(' " + message + " ');", true);

        timer.Interval = 30000;
        timer.Elapsed += new ElapsedEventHandler(timer_tick);

        // Only raise the event the first time Interval elapses.
        timer.AutoReset = false;
        timer.Enabled = true;
    }
}

protected void timer_tick(object sender, EventArgs e)
{

//line 2 get_datasource(); GridView2.DataBind(); }

The problem is with the data in the grid view that is being displayed... since when get_datasource which is after line 1 is called the updated data is displayed in the grid view since it is a postback event but when the timer event handler is calling the timer_tick event the get_datasource function is called but after that the updated data is not visible in the grid view. It is nnot getting updated since the timer_tick is not a post back event

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about timer