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]["你的列"] = 修改的值;}
posted @ 2018-05-15 12:59  一念如是  阅读(17336)  评论(0编辑  收藏  举报