asp.net FormView控件(使用对象数据源)插回传 [英] asp.net formview (using object datasource) postback insert

查看:168
本文介绍了asp.net FormView控件(使用对象数据源)插回传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ObjectDataSource控件和默认模式=插入一个FormView ......但之后,我插项目,如果你刷新页面一次又一次地插入....我试过Is.postback控制,但想不出prevent this.Is反正有做呢?

I have a formview which using objectdatasource and default mode = insert... but after I inserted item if you refresh page inserting again and again....I tried Is.postback control but couldnt prevent this.Is there anyway to do it ?

推荐答案

这是一种常见的根本问题,这是一个有点难以解决的问题。有一对夫妇的方式来处理它。你可以使用一种方法来检测刷新页面,如下所示:

That is a common fundamental problem, which is a little harder to solve. There are a couple of ways to deal with it. You could use a means to detecting a page refresh, like this:

  • http://www.codeproject.com/Articles/68371/Detecting-Refresh-or-Postback-in-ASP-NET
  • http://www.codeproject.com/Articles/10240/Detecting-Page-Refresh
  • http://www.jaredlog.com/?p=13

这是一个服务器端的方法来对事件作出响应;那么你可以以编程方式取消插入。另一种选择是,以检查是否同一数据previously贴,然后不要做一个双插入。另外,我们使用Telerik的的RadAjaxPanel(虽然在UpdatePanel应该工作一样也行)来处理这个问题,作为POST操作都通过AJAX完成的,所以当你刷新刷新原来的GET请求。

This is a server-side approach to responding to events; you could then cancel the insert programmatically. Another option is to check to see if the same data previously posted, and then don't do a double insert. Alternatively, we use the RadAjaxPanel from Telerik (though the UpdatePanel should work the same too) to handle this, as the POST operations are done through AJAX, so when you refresh it refreshes the original GET request.

这篇关于asp.net FormView控件(使用对象数据源)插回传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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