Programmatically change UpdateMethod of ObjectDataSource

I want to change the UpdateMethod of an ODS. I've tried changing it but it keeps going to the method initially defined. The parameters are the same between the two methods.

The docs indicate that you can Set the property and you don't get a compile error.

Any thoughts



Answer this question

Programmatically change UpdateMethod of ObjectDataSource

  • Nonu_k

    From the code above, shouldn't it be
    ObjectDataSource2.UpdateMethod = "UpdateContact"
    Have you tried placing a breakpoint on the CustomerDS.UpdateMethod = "UpdateContact" 
    line to make sure it is executed as expected
    Charles

  • Richard Berg MSFT

    Hi,

    Have you done exactly as in http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.updatemethod.aspx

    If it does not work please post your code.

    Charles

  • John_Mac

    I looked at that but it only sets it in the page and doesn't change it in the code behind.

    In the page, let's say I have:

    <asp:objectdatasource
              id="ObjectDataSource2"
              runat="server"
              updatemethod="UpdateCustomer"
              typename="CustomerLogic">
    </asp:objectdatasource>

     

    In the code behind, I have:

    Protected Sub ContactDetails_ModeChanged(......) Handles ContactDetails.ModeChanged
          If ContactDetails.CurrentMode = Editing Then
                CustomerDS.UpdateMethod = "UpdateContact"
          End If
    End Sub

    When I click Update in the ContactDetails, it uses UpdateCustomer rather than UpdateContact.


  • dr.acv

    If you place a breakpoint in UpdateCustomer and use the immediate window to read the value of the ObjectDataSource2.UpdateMethod, does it say UpdateCustomer or UpdateContact

    Charles


  • rheaney

    Sorry, my bad. ObjectDataSource2 and CustomerDS are the same thing. I just forgot to change it when I cut and paste from the example.

    I did place a breakpoint on the line and it fires fine. Set a breakpoint for when it changed. It catches my programmatic change but never catches it reverting back.


  • Programmatically change UpdateMethod of ObjectDataSource