C
C#2y ago
Guns

C# Data Table issue

https://pastebin.com/DSHwSh0M based on this program, I need to set the values of the Old PS A11Y State in the mergedDataTable to the values from the initial target file/worksheet and technically the targetDataTable. what do i need to changed? Rn this is how it is being done, but for unknown reasons, even after updating the file the values for that column (Old PS A11Y State) are not being updated;
foreach (DataRow targetRow in targetRows)
{
targetRow.SetField("Status", updatedStatus);

DataRow updatedRow = syncedDataTable.NewRow();
updatedRow["Finding ID"] = findingId;
updatedRow["Status"] = updatedStatus;
syncedDataTable.Rows.Add(updatedRow);

DataRow mergedRow = mergedDataTable.NewRow();
mergedRow["Finding ID"] = findingId;
mergedRow["eA State"] = sourceDataTable.Rows[i].Field<string>("Status");
// assuming the issue is here;
mergedRow["old PS A11Y State"] = targetDataTable.Rows[i].Field<string>("Status");

mergedRow["new PS A11Y State"] = updatedStatus;
mergedDataTable.Rows.Add(mergedRow);
}
foreach (DataRow targetRow in targetRows)
{
targetRow.SetField("Status", updatedStatus);

DataRow updatedRow = syncedDataTable.NewRow();
updatedRow["Finding ID"] = findingId;
updatedRow["Status"] = updatedStatus;
syncedDataTable.Rows.Add(updatedRow);

DataRow mergedRow = mergedDataTable.NewRow();
mergedRow["Finding ID"] = findingId;
mergedRow["eA State"] = sourceDataTable.Rows[i].Field<string>("Status");
// assuming the issue is here;
mergedRow["old PS A11Y State"] = targetDataTable.Rows[i].Field<string>("Status");

mergedRow["new PS A11Y State"] = updatedStatus;
mergedDataTable.Rows.Add(mergedRow);
}
e.g; on the fist run i.e when the file is not yet synced the data grid view should look like this; v1;
finding id, ea state,old, new
1a, closed, open, closed
finding id, ea state,old, new
1a, closed, open, closed
then after updating the file and re opening the updated file, the data grid view should look like this; v2;
finding id, ea state,old, new
1a, closed, **closed**, closed
finding id, ea state,old, new
1a, closed, **closed**, closed
but instead the datagrid view is still looking like the first version...
1 Reply
Guns
GunsOP2y ago
the full code;
Want results from more Discord servers?
Add your server