Determination of Whether an Action Was Initiated in the UI
In the RowInserting, RowInserted, RowUpdating, RowUpdated, RowDeleting, and RowDeleted event handlers, you can check whether the action was initiated in the UI. You should use the ExternalCall property of the event arguments for this.
The ExternalCall property returns true if the deletion has been initialized in the UI or through the web services APIs. If you do not need to invoke particular logic for data modifications made in code (such as the removal of a record), you can exit the method if the ExternalCall property is false as follows.
if (!e.ExternalCall) return;