locked
ObjectDataSource Updating Event and FormView Updated Event RRS feed

  • Question

  • User435566049 posted

    Hello,

    I have noticed in my web application that when I set e.Cancel = true in my ObjectDataSource Updating Event, the FormView Updated Event still fires.

    1) Will FormView Updated Event fire even when I cancel the ObjectDataSource Updating Event?

    2) If the first question is yes, how do I stop ObjectDataSource Updating Event from firing?

    Wednesday, June 29, 2011 6:13 PM

Answers

  • User60291871 posted

    Hi, assuming you are using the ObjectDataSource for retrieving data for your FormView (by setting the FormviewdataSourceID to the ObjectDataSourceID) then when issuing a FormView Update command, it is the FormView updating events that initiates the ObjectDataSource update events<o:p></o:p>

    From Microsoft MSDN: Issuing a FormView Update command Updates the current record in the data source. Raises the ItemUpdated and ItemUpdating events.<o:p></o:p>

    Hence the FormView Updating and Updated events will fire even if you cancel the ObjectDataSource updating event in code behind. Therefore, you need to stop the FormView updating event in code behind if the data conditions are not right for updating. This can be achieved in the same way by using e.cancel in the FormView Updating event.<o:p></o:p>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 29, 2011 6:59 PM

All replies

  • User60291871 posted

    Hi, assuming you are using the ObjectDataSource for retrieving data for your FormView (by setting the FormviewdataSourceID to the ObjectDataSourceID) then when issuing a FormView Update command, it is the FormView updating events that initiates the ObjectDataSource update events<o:p></o:p>

    From Microsoft MSDN: Issuing a FormView Update command Updates the current record in the data source. Raises the ItemUpdated and ItemUpdating events.<o:p></o:p>

    Hence the FormView Updating and Updated events will fire even if you cancel the ObjectDataSource updating event in code behind. Therefore, you need to stop the FormView updating event in code behind if the data conditions are not right for updating. This can be achieved in the same way by using e.cancel in the FormView Updating event.<o:p></o:p>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 29, 2011 6:59 PM
  • User435566049 posted

    Thank you very much for your answer, I really appreciate it.

    Thursday, June 30, 2011 3:44 PM