Formview edit displaying the same record even when I change the parameter

C

Chris

I have a treeview control, which I use to select a row in a table which will
be used to populate a formview. Depending on what node is selected in the
treeview I want the formview to be either in update or insert mode.

Protected Sub tvwmenu_SelectedNodeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tvwmenu.SelectedNodeChanged

ViewState("menuid") = menuid
ViewState("parentid") = parentid
If menuid <> 0 Then
fvwPage.ChangeMode(FormViewMode.Edit)
Else
fvwPage.ChangeMode(FormViewMode.Insert)
End If

End Sub

The problem is that when I go to change the objectdatasource parameter when
I go into edit mode it only fires once so the same record displays in the
formview. When I swap from edit to insert and back I can select a new record
to update, but only once until I swap back to insert and then back to edit.
Hope this makes sense. What I am doing wrong? Regards, Chris.

Protected Sub odsPage_Selecting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles
odsPage.Selecting
e.InputParameters("menuid") = CInt(ViewState("menuid"))
End Sub

Protected Sub odsPage_Updating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles
odsPage.Updating
e.InputParameters("menuid") = CInt(ViewState("menuid"))
End Sub
 
C

Chris

OK I have figured out that the Selecting event of the ObjectDataSource only
seems to fire when you go into e.g. the edit mode for the first time. If I
swap modes i.e. go from edit to readonly and back to edit it fires
everytime. This is too much of a hack. Can anyone point me in a better
direction.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top