private void StoreValuesToDataSet() { if (DsLogs == null) { ImportDetails impDetails = new ImportDetails(CurrentConnectionManager); DsLogs = impDetails.SelectImportDetailsWithErrors(IdImport, Request.ApplicationPath); DsLogs.Tables[0].PrimaryKey = new DataColumn[] { DsLogs.Tables[0].Columns["IdRow"] }; } Hashtable newValues = new Hashtable(); foreach (GridDataItem item in grdImportDetails.Items) { if (item.IsInEditMode) { if (IsItemModified(item)) { item.ExtractValues(newValues); DataRow row = DsLogs.Tables[0].Rows.Find(item["RowNumber"].Text); if (row.RowState != DataRowState.Deleted) { row["CostCenter"] = DSUtils.GetValueToInsertInDataSet(newValues["CostCenter"]); row["ProjectCode"] = DSUtils.GetValueToInsertInDataSet(newValues["ProjectCode"]); row["WPCode"] = DSUtils.GetValueToInsertInDataSet(newValues["WPCode"]); row["AccountNumber"] = DSUtils.GetValueToInsertInDataSet(newValues["AccountNumber"]); row["AssociateNumber"] = DSUtils.GetValueToInsertInDataSet(newValues["AssociateNumber"]); row["Quantity"] = DSUtils.GetValueToInsertInDataSet(newValues["Quantity"]); row["UnitQty"] = DSUtils.GetValueToInsertInDataSet(newValues["UnitQty"]); row["Value"] = DSUtils.GetValueToInsertInDataSet(newValues["Value"]); row["CurrencyCode"] = DSUtils.GetValueToInsertInDataSet(newValues["CurrencyCode"]); } } } } }
/// <summary> /// Loads the data /// </summary> private void LoadEditableGrid() { if (DsLogs == null) { ImportDetails impDetails = new ImportDetails(CurrentConnectionManager); DsLogs = impDetails.SelectImportDetailsWithErrors(IdImport, Request.ApplicationPath); //Accept changes so that all rows in the dataset have RowState Unchanged DsLogs.AcceptChanges(); grdImportDetails.DataSource = DsLogs; } else { grdImportDetails.DataSource = DsLogs; } DsLogs.Tables[0].PrimaryKey = new DataColumn[] { DsLogs.Tables[0].Columns["IdRow"] }; }