I've been playing around with the new GridView control and so far it's been quite nice with the new gimmicks -- cuts about 90% of my code straight out. However... Inserting isn't implemented yet. It is, however, implemented in the DetailsView control.
So I decided to tackle the problem this way:
-------------> View1 => MyGridView, MyInsertButton
-------------> View2 => MyDetailsView
I have a form with a multiview. The multiview has two views, one with a Gridview and a button entitled 'Insert', the other with a DetailsView. For viewing/editing/deleting, I use the GridView. For insertion, I switch views to the DetailsView and change mode to insert. So far so good.
Next, when the DetailsView changes modes (back to readonly), I have it switch back to the original view. Here's where the error occurs: any other action throws the following exception...
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code.
System.Web.HttpException: Failed to load viewstate. The control tree into
which viewstate is being loaded must match the control tree that was used to
save viewstate during the previous request. For example, when adding controls
dynamically, the controls added during a post-back must match the type and
position of the controls added during the initial request.
So -- where is the problem coming from? Am I getting the events screwed up? Is there something I'm forgetting? Or is there really something amiss..?
Just in case, here's the code:
Sub AddActivity_Click(ByVal sender As Object, ByVal e As System.EventArgs)
AdminMultiView.ActiveViewIndex = 4
Sub DetailsView1_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If Not DetailsView1.CurrentMode = DetailsViewMode.Insert Then
AdminMultiView.ActiveViewIndex = 0