protected override void OnModeChanging(DetailsViewModeEventArgs e) { _cancelingEdit = e.CancelingEdit; base.OnModeChanging(e); if (AllowChangeViewMode) { if (TableDataSourceView != null && !e.Cancel && e.CancelingEdit && Parent is View) { if (TableDataSourceView.HasNewRow) { e.Cancel = true; } TableDataSourceView.CancelEdit(); } } }
protected override void OnModeChanged(EventArgs e) { if (AllowChangeViewMode) { if (TableDataSourceView != null && CurrentMode == DetailsViewMode.ReadOnly && (TableDataSourceView.HasNewRow || TableDataSourceView.IsEditRow)) { if (_cancelingEdit && !(Parent is View)) { TableDataSourceView.CancelEdit(); } TableDataSourceView.EndEdit(); } if (TableDataSourceView != null && CurrentMode == DetailsViewMode.Edit && !TableDataSourceView.IsEditRow) { TableDataSourceView.BeginEdit(); } } base.OnModeChanged(e); }