当我使用c#多次单击保存按钮时,如何停止存储在gridview中的重复数据? [英] How to stopping duplicate data stored in gridview when I click save button more than one time using c#?

查看:94
本文介绍了当我使用c#多次单击保存按钮时,如何停止存储在gridview中的重复数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,

当我使用C#多次单击保存按钮时,如何停止存储在网格视图中的重复数据?


注意:
点击保存按钮时,(该保存按钮在几分之一秒内点击了一次)
现在复制存储在网格视图中的数据.

如何解决此问题/如何避免重复记录?


通过Mohan.

Dear sir,

How to stopping duplicate data stored in grid view when i click save button more than one time using c#?


Note :
At the time of click the save button, (more than one click in fraction of seconds for that save button)
now duplicate data''s stored in grid view.

How to solve this problem/How to avoid this duplicate records?


By Mohan.

推荐答案

当用户双击保存按钮时,我还面临着重复记录被保存的问题.因此,我尝试了以下方法.在这里,JavaScript函数"HideButton()"在单击保存按钮时将其隐藏,因为不允许用户再次单击该按钮.页面刷新后,该按钮会重新出现.

I was also facing the problem of duplicate records getting saved when user double clicks on save button. So I tried the below approach. Here the JavaScript function "HideButton()" hides the save button when its clicked there by not allowing the user to click on it again. The button reappears after the page refreshes.

<asp:ImageButton ID="btnSaveNotes" runat="server" OnClick="btnSaveNotes_Click" OnClientClick="HideButton()" />

<script language="javascript">
function HideButton()
{
  var SaveNotes = document.getElementById('<%=btnSaveNotes.ClientID %>');
  SaveNotes.style.display = 'none';
}
</script>


之所以会出现此问题,是因为保存按钮的click事件触发了. 引用此链接,遇到与您同样的问题,
解决主题可能有用吗
保存时为双重数据 [
this problem can be raised because save button''s click event is firing twise.
Refer this link, having same problem like you have,
May it be useful to solve topic
Double data when saving[^]
Happy Coding!
:)


这篇关于当我使用c#多次单击保存按钮时,如何停止存储在gridview中的重复数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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