Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi..

I have one Asp.net Page that contains gridView and Save Button.
So,here am selecting few rows and Click on Saving it will Save in Database.
while Saving When i click on Page reload it will Saving Multiple Times.
So, How do i prevent Saving Multiple times.


Thanking You in Advance..
Avinash
Posted

You can put condition inside your query like
Ex.
if not exists(select col1 from table1 where col1=@col1)
begin 
  insert into table1(col1)values(@col1)
end
 
Share this answer
 
Can you paste your code?

As a suggestion, check if any row is selected or not before save in DB , also clear selection after save.
 
Share this answer
 
You have to implement PRG pattern to avoid above issue.Please read below link for more info.

PRG:
What is the PRG Pattern ?
PRG stands for "Post/Redirect/Get"
Instead of returning an HTML page directly,
The POST operation returns a redirection command (using the HTTP 303 response code (sometimes 302) together with the HTTP "Location" response header),
Instructing the browser to load a different page using an HTTP GET request
The result page can then safely be bookmarked or reloaded without unexpected side effects

Post-Redirect-Get with ASP.NET
 
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