I have a FormView which I would like to open in insert mode only if the form contains no data. I’ve tried the following if statement:
If True Then
If SomeFormView.DataItemCount = 0 Then
SomeFormView.ChangeMode(FormViewMode.Insert)
Else
SomeFormView.ChangeMode(FormViewMode.Edit)
End If
End If
but it opens in insert whether empty or not?
You need to wait until the
FormViewhas been databound before doing that check, otherwise you’ll always get “true” (because it does have zero items until you bind it to whatever data source is providing it with said items). You could do this in the databound event, preferably: