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();
}
问题是与正在显示...当get_datasource这是1号线后调用,因为它是更新后的数据显示在网格视图因为在网格视图中的数据回发事件,但是当计时器事件处理程序正在调用timer_tick事件时,会调用get_datasource函数,但在此之后,更新后的数据在网格视图中不可见。由于timer_tick不是回发事件,因此它没有得到更新ASP.NET计时器事件
唷,这是一个令人困惑的望着消息 - Ratnajyothi先生,你能不能再 - 格式化它看起来可读? 此外,您将无法在ASP.NET应用程序中使用“Timer”来导致回发,因为它只在服务器上运行。您需要改用JavaScript客户端脚本。 – 2010-05-10 05:08:25