After performing a FormView.InsertItem, I am unable to read the new values from the bound object within the LLBLGenProDataSource that the FormView is bound to.
I have tracing turned on, I can see the insert happen, and the data does make it into the database, yet when I examine the contents of LLBLGenProDataSource.EntityCollection(0) (there is only one item in the collection) I do not see the values from the FormView.....yet, they are somehow being inserted into the database.
Relevant code:
<llblgenpro:LLBLGenProDataSource ID="llbDataSource" runat="server" MaxNumberOfItemsToReturn="1"
DataContainerType="EntityCollection"
EntityCollectionTypeName="Domain.CollectionClasses.MetricCollection, Domain"
LivePersistence="True" ThrowExceptionOnIllegalFieldInput="true" />
Private Sub frmEdit_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles frmEdit.ItemCreated
If Me.llbDataSource.EntityCollection.Count = 0 Then
Me.frmEdit.ChangeMode(FormViewMode.Insert)
Me.llbDataSource.EntityCollection.Add(New MetricEntity)
Me.frmEdit.DataBind()
Else
LoadDropdowns()
End If
End Sub
Private Sub cmdSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSave.Click
If Me.frmEdit.CurrentMode = FormViewMode.Edit Then
Me.frmEdit.UpdateItem(False)
ElseIf Me.frmEdit.CurrentMode = FormViewMode.Insert Then
Me.frmEdit.InsertItem(False)
'Me.llbDataSource.DataBind() 'NOPE!
Response.Redirect("~/MetricDetail.aspx?MetricCode=" & Me.llbDataSource.EntityCollection(0).Fields("MetricCode").CurrentValue.ToString)
End If
End Sub