DetailsViewMode.Insert
(1)
DetailsViewMode
(1)
DetailsView
(1)
DvTransient.DefaultMode
(1)
GvTransient.Rows.Count
(1)
Insert
(1)
Update
(1)
Delete
(1)

DetailsView defaultMode question

Asked By Seth Williams
06-May-08 12:42 PM
I have a Master/Detail page - the DetailsView is set to ReadOnly, and
AutoGenerates Delete/Edit/Insert buttons
The Gridview has records - when a record is selected, the DetailsView is
populated
I can successfully Delete/Insert/Update - no problem

However, since it's set to ReadOnly, the DetailsView is not visible when no
records are in the Gridview and the corresponding table
I need it to be visible, so I can choose the Insert capabilities, the first
time (once in production)

If I set the DetailsView to Insert for the defaultMode, it never changes
from that mode, even when a record is selected from the Gridview

I tried adding a 'CheckMode' sub, and ran it in the INSERTED and DELETED
events of the DetailsView, along with Page_Load:

If gvTransient.Rows.Count = 0 Then
dvTransient.DefaultMode = DetailsViewMode.Insert
Else
dvTransient.DefaultMode = DetailsViewMode.ReadOnly
End If

However, the defaultmode property apparently is only available when the page
initially loads, and can not be changed not on postback

Is there any other way I can achieve what I'm needing?
Post Question To EggHeadCafe