Change Datarow field value

D Todorov picture D Todorov · May 10, 2016 · Viewed 24.5k times · Source

First I have last update file from DB

DataTable excelData = ReadSCOOmega(lastUploadFile);

, after this iterate over this data

foreach (DataRow currentRow in rows)
{
     currentRow.
}

Is that possible to change da data in the foreach loop.I can access only the value of this data

currentRow.Field<object>("Some column name")

but not to change it.My idea is selected.I have a multiple deals in excel file and when is upload to DB, I need to make changes in this file.Is that possible or I need to store the data in other collection?

Answer

Abdellah OUMGHAR picture Abdellah OUMGHAR · May 10, 2016

You can do that like :

foreach (DataRow currentRow in excelData.Rows)
{
    currentRow.BeginEdit();
    currentRow["ColumnName"] = value;
    //.....
    currentRow.EndEdit();
}