Master/Details cloning a record?

W

woodfoot

I would like to add a button to my Gridview so that when I click it, it
prepopulates a Formview template with that record's data so that the user can
make changes where necessary. They then would be able to press a button on
the FormView that inserts the new form's data as a new record. Basically the
button click would be cloning a record and save the user quite a bit of
typing.

I'm sure this is possible. I do have the select, update, and insert
already working fine.


Any help/guidance would be much appreciated. Thx!
 
W

woodfoot

Thanks, I have looked at those examples but they just don't quite do it for me.

The "VB Master-Details Insert" example almost does it because the State is
prepopulated (albeit disabled), but I have a form with some 50 plus items.

I essentially would like I'm going to edit the record because it all
prepopluated with previous input but want to insert it as a new record after
the user has made some changes. Clone...modifiy where needed...insert as new.

I guess it would be like changing the mode of the form to use the
insertcommand of the formview as oopse to the editcommand.....

I hope i wasn't to confusing.
 
P

Phillip Williams

Essentially what you are looking for is to populate the empty textboxes that
are generated upon inserting a new record with the entries of the selected
row on the GridView.

You can do that by consuming the ItemCreated event of either the DetailsView
or FormView. So if you build on the QuickStart tutorial sample, I would
write a method like this:

Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, ByVal e As
EventArgs)
'execute the following only when inserting a new record
If DetailsView1.CurrentMode = DetailsViewMode.Insert Then
'each row corresponds to a BoundField on the DetailsView definition
'Row(1) is the second field: the au_lname field
'when it renders in insert mode, it renders a cell that has a
textbox in it
'we want to set the textbox.text property to the au_lname from the
selected
'row on the GridView
Ctype(DetailsView1.Rows(1).Cells(1).Controls(0), TextBox).Text= _
GridView1.SelectedRow.Cells(2).Text
'continue to set the other textboxes on the record to be inserted
using
'the same process
End If

End Sub
 
W

woodfoot

Thanks - I'll hack at that and see if I can get that to work. Will this work
in a FormView though? "Rows" is not a property of the FormView.

Please bear with me and thanks for your help.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top