Пример #1
0
        private bool HandleInsertCallback(int affectedRows, Exception ex) {
            DetailsViewInsertedEventArgs dea = new DetailsViewInsertedEventArgs(affectedRows, ex);
            dea.SetValues(_insertValues);
            OnItemInserted(dea);

            _insertValues = null;
            if (ex != null && !dea.ExceptionHandled) {
                // If there is no validator in the validation group that could make sense
                // of the error, return false to proceed with standard exception handling.
                // But if there is one, we want to let it display its error instead of throwing.
                if (PageIsValidAfterModelException()) {
                    return false;
                }
                dea.KeepInInsertMode = true;
            }

            if (IsUsingModelBinders && !Page.ModelState.IsValid) {
                dea.KeepInInsertMode = true;
            }

            if (!dea.KeepInInsertMode) {
                DetailsViewModeEventArgs eMode = new DetailsViewModeEventArgs(DefaultMode, false);
                OnModeChanging(eMode);
                if (!eMode.Cancel) {
                    Mode = eMode.NewMode;
                    OnModeChanged(EventArgs.Empty);
                    RequiresDataBinding = true;
                }
            }
            return true;
        }
 private bool HandleInsertCallback(int affectedRows, Exception ex)
 {
     DetailsViewInsertedEventArgs e = new DetailsViewInsertedEventArgs(affectedRows, ex);
     e.SetValues(this._insertValues);
     this.OnItemInserted(e);
     this._insertValues = null;
     if ((ex != null) && !e.ExceptionHandled)
     {
         if (this.PageIsValidAfterModelException())
         {
             return false;
         }
         e.KeepInInsertMode = true;
     }
     if (!e.KeepInInsertMode)
     {
         DetailsViewModeEventArgs args2 = new DetailsViewModeEventArgs(this.DefaultMode, false);
         this.OnModeChanging(args2);
         if (!args2.Cancel)
         {
             this.Mode = args2.NewMode;
             this.OnModeChanged(EventArgs.Empty);
             base.RequiresDataBinding = true;
         }
     }
     return true;
 }