c# 怎么更改DataTable 中某列的值?

DataColumns dc = td.Columns["你的列"];
int inx = dc.Ordinal;
td.Columns.Remove(dc);
dc.DefaultValue=你的值;
td.Columns.Add(dc);
dc.SetOrdinal(inx);

我觉得下面的方法更简单
dt.Rows[rowIndex][colIndex] = newValue;

for(int i = 0; i < dt.Rows.Count; i++){ dt.Rows[i]["你的列"] = 修改的值;}

你可能感兴趣的:(教程)