By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.ObjectDataSourceSelectin gEventArgs) 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.ObjectDataSourceMethodEv entArgs) Handles
odsPage.Updating
e.InputParameters("menuid") = CInt(ViewState("menuid"))
End Sub
May 7 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"Chris" <no****@nospam.comwrote in message
news:ui*************@TK2MSFTNGP06.phx.gbl...
>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.ObjectDataSourceSelectin gEventArgs) 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.ObjectDataSourceMethodEv entArgs) Handles
odsPage.Updating
e.InputParameters("menuid") = CInt(ViewState("menuid"))
End Sub

May 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.