I'm using a formview control that displays a gridview on a page that shows all of the logs currently in the system. If a user wants to create a new log, the formview shows a version of the page that allows that - upon clicking add the formveiw switches back to the item view and shows the gridview with the newly added item.
If I 'refresh' the page at that point, I get another copy of the last item added. I can make hundreds of copies this way.
The page causes the insert object event on the datasource to keep firing.
How do I prevent this?
I found a fix - it's a bit of a hack.
After doing the insertobject I do a response.redirect to the same page and that clears out the postback data.
For a small app that is fine.
For a larger app that can afford a framework level soultion you can implement an HttpModule named RefreshTrapper (by Dino Esposito?) which does a lot of work to find out if it is a page refresh or not and then sets IsPostback=False in:
Protected Overrides Function DeterminePostBackMode() As System.Collections.Specialized.NameValueCollection
There is a lot of code to implement something like this, so your workaround is fine.
Joe
Copyright (c) Marimer LLC