简体   繁体   中英

Change Datarow field value

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?

You can do that like :

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

You can use indexer to set the data stored to the field: currentRow["columnName"] = value .

See MSDN DataRow.Item Property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM