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

Discussion in 'ASP .Net' started by Chris, May 7, 2007.

  1. Chris

    Chris Guest

    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
    Chris, May 7, 2007
    #1
    1. Advertising

  2. Chris

    Chris Guest

    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" <> wrote in message
    news:...
    >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
    >
    Chris, May 7, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. André
    Replies:
    0
    Views:
    3,730
    André
    Jun 25, 2006
  2. OS538DAV
    Replies:
    0
    Views:
    872
    OS538DAV
    Nov 22, 2006
  3. KenK

    FormView - Single Record edit

    KenK, Jan 15, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    104
  4. Phil

    edit single record in formview

    Phil, Jan 23, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    136
  5. André
    Replies:
    0
    Views:
    434
    André
    Jun 25, 2006
Loading...

Share This Page