Last post Jun 30, 2011 03:44 PM by TBossAZ
Jun 29, 2011 06:13 PM|TBossAZ|LINK
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?
Jun 29, 2011 06:59 PM|smcoxon|LINK
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
From Microsoft MSDN: Issuing a FormView Update command Updates the current record in the data source. Raises the ItemUpdated and ItemUpdating events.
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.
Jun 30, 2011 03:44 PM|TBossAZ|LINK
Thank you very much for your answer, I really appreciate it.