/// <summary> /// Stores the current values in the DataGrid back into the /// specified DataSet and table /// </summary> /// <param name="ds">DataSet</param> /// <param name="tableName">Table Name</param> public override void BindBack(DataSet ds, string tableName) { if (this.EditItemIndex >= 0) { DataGridItem item = this.Items[this.EditItemIndex]; int CellNumber = 0; int DataIndex = item.DataSetIndex; foreach(TableCell cell in item.Cells) { // Need to check HasControls because if a column is set to ReadOnly, // HasControls() returns false. Trying to process the controls collection // when HasControls() is false, throws an exception. if (cell.HasControls()) { DataGridColumn column = this.Columns[CellNumber]; if (column is BoundColumn) { BoundColumn BoundCol = (BoundColumn)column; if (cell.Controls[0] is TextBox) { TextBox txtBox = (TextBox)cell.Controls[0]; ds.Tables[tableName].Rows[DataIndex][BoundCol.DataField] = txtBox.Text; } } } CellNumber++; } } }Within your new BusinessObject.cs e.g. ABusinessObject before your final data BusinessObjects. Kevin will probably improve on this, but this does work for now. This method receives two int values to differenciate it from the mm version of SaveDataSet. In this case the correct datarow is assigned to the "this.DataRow". Error icons will now appear as usual; though I am missing the error message at the bottom/top of my page.
/// <summary> /// (10) Saves the current DataSet's specified table to the default database /// </summary> /// <param name="tableName">Table Name</param> /// <returns>mmSaveDataResult enum value</returns> /// <param name="currentGridRow">Current Grid Row</param> /// <param name="currentDataRow">Current Data Row</param> public virtual mmSaveDataResult SaveDataSet(string tableName, int currentGridRow, int currentDataRow) { // Save the specified row number this.RowNum = currentDataRow; // Get the corresponding data row DataSet ds = this.GetCurrentDataSet(); this.DataRow = ds.Tables[tableName].Rows[currentDataRow]; // Save the data mmSaveDataResult result = this.SaveDataSet(ds, tableName); // Reset the row number to zero this.RowNum = 0; // Return the result return result; }>Hello Kevin,
>public virtual void BindBack(DataSet ds, string tableName) >{ > if (this.EditItemIndex >= 0) > { > DataGridItem item = this.Items[this.EditItemIndex]; <----- A > int CellNumber = 0; > > foreach(TableCell cell in item.Cells) > { > // Need to check HasControls because if a column is set to ReadOnly, > // HasControls() returns false. Trying to process the controls collection > // when HasControls() is false, throws an exception. > if (cell.HasControls()) > { > DataGridColumn column = this.Columns[CellNumber]; > if (column is BoundColumn) > { > BoundColumn BoundCol = (BoundColumn)column; > if (cell.Controls[0] is TextBox) > { > TextBox txtBox = (TextBox)cell.Controls[0]; > ds.Tables[tableName].Rows[EditItemIndex][BoundCol.DataField] = txtBox.Text; <---- B > } > } > } > CellNumber++; > } > } >} >