I have a simple vb.net 2005 application using an SQLserver database
There is a form , employees that has a grid view and a detail view control
The grid displays data and has a "Select" link as the leftmost column. Clicking on this displays employee details in the detail view.
The detail view further has Edit, Delete and New links, that help to maintain data.
My problem is this -
when the last employee record is deleted, the detail view must go to insert mode , so that the user can enter fresh data.
The defaultmode property of thd detail view is set to "Read only " at design time.
Right now, when the last record is deleted, the detail view disappears from the screen , as it is still in read-only mode
I have written the following code, it works in all cases, except when the last record on screen is deleted.
What am I missing ?
Expand|Select|Wrap|Line Numbers
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
- Dim mycount As Integer = GridView1.Rows.Count
- If mycount > 0 Then
- DetailsView1.DefaultMode = DetailsViewMode.ReadOnly
- Else
- DetailsView1.DefaultMode = DetailsViewMode.Insert
- End If
- DetailsView1.Visible = True
- End Sub
Nanda