Ejemplo n.º 1
0
        private bool HandleInsertCallback(int affectedRows, Exception ex) {
            FormViewInsertedEventArgs fea = new FormViewInsertedEventArgs(affectedRows, ex);
            fea.SetValues(_insertValues);

            OnItemInserted(fea);

            _insertValues = null;
            if (ex != null && !fea.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;
                }
                fea.KeepInInsertMode = true;
            }

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

            if (!fea.KeepInInsertMode) {
                FormViewModeEventArgs eMode = new FormViewModeEventArgs(DefaultMode, false);
                OnModeChanging(eMode);
                if (!eMode.Cancel) {
                    Mode = eMode.NewMode;
                    OnModeChanged(EventArgs.Empty);
                    RequiresDataBinding = true;
                }
            }
            return true;
        }