当数据库表受到影响时自动更新该网格 [英] auto update that grid whene ever db table get affected
本文介绍了当数据库表受到影响时自动更新该网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1)我想在数据库表受到影响时自动更新网格,因为我的页面中使用了多个小部件,所以我无法重新加载页面
2)我只需要重新加载动态用户控件的网格视图
3)我为放置项设置了单独的用户控件,如果我在一个用户控件上放置项,它将影响另一个用户控件的网格
这些都是动态窗口小部件,因此我需要一些示例代码来自动更新数据库表,是否有可能影响网格?
1) i want to update a grid automatically when ever database table get affected am using multiple widgets in my page so i cant reload the page
2) i just need to reload a dynamic user control''s grid view
3) i ve separate user control for put entry ,if i put entry on one user control it should affect another user control''s grid
these are all dynamic widgets so i need some sample code to auto update that grid whene ever db table get affected is it possible?
推荐答案
1-这是不可能的.您的页面不知道何时更改表行.如果您有新数据,您所能做的就是定期AJAX调用CHECK.
2-这不是一个新问题.但是,网格视图是服务器概念,在客户端上不存在.除非您使用骇人的ASP.NET AJAX库假装您正在做什么,否则您无法真正重新加载它.
3-不,不可能.最好的办法就是让所有这些页面都调用计时器,以尝试找出是否需要它们.
1 - this is not possible. Your page cannot know when a table row is changed. All you can do is regular AJAX calls to CHECK if you have new data.
2 - This is not a new question. But, a grid view is a server concept, it does not exist on the client. You can''t really reload it unless you use the hacky ASP.NET AJAX library to pretend that is what you are doing.
3 - No, it''s not possible. The best you can do, is have all these pages calling timers to try to find out if there is data they need.
这是一篇有关通知服务的好文章:
使用SqlDependency和SqlCacheDependency的查询通知 [ http://msdn.microsoft.com/en-us/library/x28wfk74.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ms172133%28v = vs.80%29.aspx [ ^ ]
SQL Server通知服务 [ ^ ]
--Amit
Hi,
Here is a nice article on notification services:
Query Notification using SqlDependency and SqlCacheDependency[^]
Check this also:
http://msdn.microsoft.com/en-us/library/x28wfk74.aspx[^]
http://msdn.microsoft.com/en-us/library/ms172133%28v=vs.80%29.aspx[^]
SQL Server Notification Services[^]
--Amit
好吧,您可以使用Timer
看看这个例子将指导您
Hi ,
Well you can do it usingTimer
Chech this example will guide you
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="2000">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</div>
protected void Timer1_Tick(object sender, EventArgs e)
{
//Rebind your Gridview
}
最好的问候
米特瓦里(M.Mitwalli)
Best Regards
M.Mitwalli
这篇关于当数据库表受到影响时自动更新该网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文