I have a formview on a web form that is set to default Readonly mode.
The problem with this is that when there are no records to show the
formview does not appear. I would like for the formview to default to
insert mode if there is not a record and if there is a record to
default to edit mode. I added the following code to my formview but
it is now defaulting to Insert mode regardless if there is a record or
not.
Protected Sub FormView1_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles FormView1.PreRender
If FormView1.DataItemCount = 0 Then
FormView1.ChangeMode(FormViewMode.Insert)
End If
End Sub
Not sure what I'm doing wrong.