Refreshing a page causes databound gridview to re update datasource.

M

Mike Grace

Hi,

I have a gridview which is using a SqlDataSource to update a table.

The SqlDatasource is using a stored procedure to update the table.

If I edit a row, change a value and click update the change is successfully
applied to the SQL table.

After this, the values in the underlying table could be changed by another
process

If I click the refresh button, when the page is redisplayed (after clicking
retry on the warning), the underlying table is updated with the old values
that were in the grid.

This is obviously very dangerous.

How can I stop this from happening?

Surely when the page is refreshed, it shouldn't reapply the updates or am I
missing something.


Regards


Mike
 
B

Brock Allen

Surely when the page is refreshed, it shouldn't reapply the updates or
am I missing something.

Have you ever read the dialog that pops up when you try to refresh after
you've previously submitted a form? The dialog usually tries to tell you
that if you hit "OK" you're going to cause the browser to repeat thelast
thing you did, which was a submit. This is a problem and is solved by either
1) user education, or if that's difficult 2) after the submit and all your
data's been saved to the database, use something like Response.Redirect(Request.Path)
to get the user back to a 'fresh' page.

-Brock
http://staff.develop.com/balle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top