protected virtual void OnRowInserted(GridViewInsertedEventArgs e) { if (RowInserted != null) { RowInserted(this, e); } }
public void InsertRow(int rowIndex) { IDataSource ds = GetDataSource(); DataSourceView view = ds.GetView(this.DataMember); GridViewRow row = this.Rows[rowIndex]; OrderedDictionary values = new OrderedDictionary(); for (int i = 0; i < this.Columns.Count; ++i) { this.Columns[i].ExtractValuesFromCell(values, (DataControlFieldCell)row.Cells[i], DataControlRowState.Insert, false); } GridViewInsertingEventArgs insertingArgs = new GridViewInsertingEventArgs(values, rowIndex); OnRowInserting(insertingArgs); if (insertingArgs.Cancel) { return; } view.Insert(values, delegate(int affectedRecords, Exception ex) { GridViewInsertedEventArgs insertedArgs = new GridViewInsertedEventArgs(affectedRecords, ex, values); OnRowInserted(insertedArgs); if (!insertedArgs.KeepInInsertMode) { this.InsertRowsCount = 0; } return(insertedArgs.ExceptionHandled); }); }