issue with detailsview

I am having issues with the detailsview getting the mode of the detailsview to change. I have a detailsview that I want the mode to change to insert if there is no information in the detailsview for that particular record. Here is the code I am using. The
issue that I am having is that when I click on the gridview, the mode is changing to insert every other time when there is not a record. It is not showing up at all the other times. Any ideas? I have been working on this for two days with no solution sight.
please assist

Private
Sub GridView1_SelectedIndexChanged(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles GridView1.SelectedIndexChanged

MultiView1.SetActiveView(View1)

If Me.DetailsView2.Rows.Count = 0
Then

Me.DetailsView2.ChangeMode(DetailsViewMode.Insert)

Me.DetailsView2.DataBind()

Else

Me.DetailsView2.ChangeMode(DetailsViewMode.ReadOnly)

Me.DetailsView2.DataBind()

End If

 

 

If Me.DetailsView3.Rows.Count = 0
Then

Me.DetailsView3.ChangeMode(DetailsViewMode.Insert)

Me.DetailsView3.DataBind()

Else

Me.DetailsView3.ChangeMode(DetailsViewMode.ReadOnly)

Me.DetailsView3.DataBind()

End If

End Sub

Try this way

MultiView1.SetActiveView(View1)

If
Me.DetailsView2.Rows.Count = 0
Then

Me.DetailsView2.ChangeMode(DetailsViewMode.Insert)

Else

Me.DetailsView2.ChangeMode(DetailsViewMode.ReadOnly)

Me.DetailsView2.DataBind()

End If

Thanks for the quick response

I tried your method and I got the same result. Every other time I click on my gridview list to get the details, the detail list in insert mode shows up. The other times nothing shows up at all.

Any thoughts?

Leave a Reply