C#怎么对接收的数据刷新
1、1.拖入ScriptManager;
2、2.拖入UpdatePanel
3、3.再加入一个定时器 Timer,设置Intervql为5秒(5000)
4、4.加一个数据控件,根据需要GridView或DataList等等,连接数据库
5、5. 设置UpdatePanel为有条件异步更新
6、6.在Timer的Tick事件中打入代码
protected void Timer1_Tick(object sender, EventArgs e)
{
UpdatePanel1.Update();
GridView1.DataBind();//如果显示数据是GridView的话
}
1、<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%= DateTime.Now.ToString() %>
<!--GridView控件在后台进行绑定--->
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<!--定时器每5秒钟刷新一次UpdatePanel中的数据-->
<asp:Timer ID="Timer1" runat="server" Interval="5000">
</asp:Timer>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick"></asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:165
阅读量:61
阅读量:97
阅读量:188
阅读量:69