What is the best way to implement “Copy to new” functionality with FormView control and content templates

I have a FormView control in an ASP.NET page. I use the InsertItemTemplate and EditItemTemplate to provide data manipulation functionality, and it is working very well. I would like to allow the user to "Copy to new" from an existing item. In other words, I want the user to be able to display an item as if they are going to edit it, then, if they click a "Copy to new" button, it will load the information from that item into an "Insert" form so they could just change the bits of data that they want, and insert the new item.

The data objects we are dealing with are fairly large so, providing this functionality will save the user a lot of data entry misery.

I have experimented with copying the existing EditItemTemplate controls in the Copy button's click event, storing them, and writing them to the new InsertItemTemplate controls, once the form is reloaded (in the Page_PreRender event). But this is pretty ugly stuff. There has to be a better/simpler way.

Does anyone have any suggestions?

Thanks very much for whatever advice you can give.

Answers


Well, why not just leave it in edit view, have Copy to new set a flag, then handle the ItemEditing event, and if in copy to new mode, then you insert a new record instead of proceeding with the update. That might save you a lot of work.

HTH.


Need Your Help

Google maps geocode API V3 not returning result in javascript function

javascript jquery google-maps geocoding google-geocoder

I'm trying to use the Google geocoder API V3 to plot a location on a map based on an address specified by the user, code is below.

RestKit: Inverse Relationship Empty After Initial Mapping

ios core-data restkit one-to-many entity-relationship

Trying to connect two entities from my API from a single response.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.