Insert template in FormView with values from another post
I'm working in ASP .NET 4.0 and using the FormView to view/edit/create items in the the DB.
As I have many fields and I want to use an existing row in the DB as a template when switching to insert mode.
Any good way of copy an existing row of values into the textboxes of the It开发者_JAVA技巧emInsert template?
A simpler method might be to actually clone the row in the DB, and go into edit mode for that row. If the user saves, then keep the row. Otherwise, kill it. Of course you'll need to handle orphaned rows appropriately in this case, say with a flag of new
which are periodically deleted from the system.
You can also simulate the above behavior by adding a DataRow
manually into a DataTable
servicing the FormView which is not actually linked to the DB. Then when the record gets saved, it will get inserted. Point being that cloning a row and editing is easier then trying to use the insert template.
精彩评论