Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
pradiprenushe 10-Aug-12 4:43am    
Are you updating record or adding? I f adding how are you adding. I get the problem but want to confirm whether that is the problem. Can you paste code to add or edit.

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.

XML
<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>
 
Share this answer
 
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!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900