Last post Apr 24, 2011 09:21 PM by Decker Dong - MSFT
Apr 22, 2011 11:40 AM|kasesock|LINK
Greetings. Long time, first time, and all that.
I have a FormView utilizing an ObjectDataSource. I'm calling the page containing this via a few methods. The previous page can send it into Edit Mode, Insert Mode, and now I'm trying to implemetn a "Copy" function. My thought has been that this "copy" function
on the previous page would open my FormView page in Edit mode, then intercept the Update method and instead fire off an Insert. This however, is giving me the "formview must be in insert mode to insert". My goal is to Select the data into the FormView (which
is fully databound) and then Insert based on that. I was thinking this was the fastest and easiest method, but it seems I can't seem to work around this. If I put the FormView in Insert mode, none of the data is there.
I'm accepting of the possibility that I might need to, after hitting "copy", place the FormView in Insert mode, select the Data from the database and insert it manually, but this seems somewhat clunky to me. I was hoping for a more elegant solution that
would lend itself to the Databinding motif, but I'm at a loss if a better method exists.
Thanks for your help!
Apr 24, 2011 03:35 PM|bobj181|LINK
you need to over ride the update event for the form. Determine if the update is truely and update and then allow it to continue with that or if it is the copy function that you are looking to do, then divert it to the copy method that you have defined.
Apr 24, 2011 09:21 PM|Decker Dong - MSFT|LINK
In my experience, I think you should write an Update Stored Procdure and bind the procdure to the ObjectDataSource. And In the ObjectDataSource, you should not only update the original row's data contents. But to do inserting as well.
Stored Procdure is better for you to choose.