private void OnInitRow(DataGridInitRowEventArgs e) { if (InitRow != null) { InitRow(this, e); } }
// Put the grid in edit mode by adding a blank row private void InsertNewRow() { // Show/Hide DELETE column ToggleDeleteColumn(false); // Get the underlying DataTable object DataTable dt = ((DataView)DataSource).Table; // If any pending changes, stop here... DataTable tmpTableOfPendingChanges = dt.GetChanges(DataRowState.Added); if (tmpTableOfPendingChanges != null) { return; } // Add the new row DataRow row = dt.NewRow(); dt.Rows.Add(row); // Initialize the row DataGridInitRowEventArgs dgire = new DataGridInitRowEventArgs(); dgire.Row = row; OnInitRow(dgire); // Goto to last page (return last index in the page) int nNewItemIndex = SetIndexesToLastPage(dt); // Turn edit mode on for the newly added row EditItemIndex = nNewItemIndex; // Tracks that a new row has just been added MustInsertRow = true; }
// EVENT HANDLER: InitRow public void InitRow(Object sender, DataGridInitRowEventArgs e) { e.Row["LastName"] = "Esposito"; }