I found that it was not working in ModeChanged. There are 3 things that I did to get this to work.
1. When I click the command button to do the copy, I had a Session field that said I clicked this button. At this time I changed the formview to be insert mode
Protected Sub cmdCopyRec_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Session("fvMailoutSub") = "CopyRec"
fvMailout.ChangeMode(FormViewMode.Insert)
End Sub
2. In the Databound, that is where I copied the fields to Session fields:
Protected Sub fvMailout_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles fvMailout.DataBound
Dim lblStatus As Label
Dim lblName As Label
If fvMailout.CurrentMode = FormViewMode.ReadOnly Then
lblStatus = fvMailout.FindControl("lblStatus")
Session("Status") = lblStatus.Text
lblName = fvMailout.FindControl("lblName")
Session("Name") = lblName.Text
End If
End Sub
3. In the Page PreRenderComplete, I copied the Session fields to the TEXT fields
Protected Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
Dim ddlStatus As DropDownList
Dim NameTextBox As TextBox
If fvMailout.CurrentMode = FormViewMode.Insert Then
If Session("fvMailoutSub") = "CopyRec" Then
Session("fvMailoutSub") = Nothing
ddlStatus = fvMailout.FindControl("ddlStatus")
ddlStatus.Text = Session("Status").ToString
NameTextBox = fvMailout.FindControl("NameTextBox")
NameTextBox.Text = Session("Name")
End If
End If
End Sub
Again, thanks for all your help!!!
I think I am now understanding all this .net coding