更新数据库时更新网页而不刷新页面 [英] Update webpage without page refresh when database is updated

查看:82
本文介绍了更新数据库时更新网页而不刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我想出了Web应用程序,在这里我对此有一些疑问,我有一个页面,该页面显示来自数据库的gridview中的项目列表,当另一个用户向数据库中添加了更多项目时,我想在其中进行网格视图我的页面可以使用新添加的项目列表进行更新,而无需刷新页面.请向朋友寻求解决方案.

问候

Vivek

Dear friends,

i have come up with web application and here i have got some quires on it, i have a page which displays list of items in a gridview from database, when database is get added with some more items by another user, i want grid view in my page to get update with newly added itemslist without page refresh.please help out friends with solution.

Regards

Vivek

推荐答案

当其他用户向数据库中添加了更多项目时,我希望页面中的网格视图能够获取不带页面的新添加项目列表的更新刷新.
一直以来,您只是说我想要".你试过了吗?想到它的可行性?您知道ASP.NET网页的工作原理吗?页面生命周期?

1.通常无法更新页面而不进行刷新,而是页面的部分渲染/更新.
2.对于Web场景,基于其他一些用户活动自动更新页面的意义较小,但有时可能需要这样做.不太有意义,因为我们在这里只能使用PULL(来自DB的数据)机制,而不能具有PUSH(来自DB的数据)机制.因此,每隔几秒钟轮询一次,然后检查是否有任何新数据是唯一的方法-导致服务器上不必要的负载.

现在,对于此轮询,您需要使用AJAX. XMLHttpRequest或ASP.NET AJAX.
放置一个计时器控件并将其设置为每几秒钟发送一次请求(例如:60秒).根据收到的响应更新用户界面.

试试并发布特定问题.
when database is get added with some more items by another user, i want grid view in my page to get update with newly added itemslist without page refresh.
All the while you just said ''I want''. Did you try? Think of it''s feasibility? Do you know how ASP.NET webpage works? Page life cycle?

1. Updating a page without refresh is not possible in general, partial rendering/update of a page is.
2. For a web scenario, updating a page automatically based on some other user activity makes less sense but may be required at times. Less sense as, we can only have PULL (data from DB) mechanism here and NOT PUSH (data from DB). Thus, polling every few seconds and checking if any new data is there is the only way - leading to unnecessary load on server.

Now, for this polling, you need to use AJAX. Either XMLHttpRequest or ASP.NET AJAX.
Put a timer control and set it to send request every few seconds (eg: 60 seconds). Based on the response received update the UI.

Try out and post specific issue.


添加一个Update面板并将您的gridview粘贴到其中,这将有助于刷新特定的gridview而不是整个页面,
然后也添加一个计时器,在Updatepanel内部;
设置计时器间隔;
在timer_tick事件中,添加用于填充gridview的代码
Add an Update panel And paste your gridview inside of it,Which will help to refresh the particular gridview instead of the whole page,
Then add a timer too,Inside Updatepanel;
Set timer interval ;
inside the timer_tick event,Add the code for filling gridview


这篇关于更新数据库时更新网页而不刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆