本文介绍了如何在特定的数据行中插入公共值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在特定行的所有列中插入值11. 假设我想要插入此值第一行如
dt.Tables [0] .Rows [1]有人可以提供代码吗?
解决方案首先,第一行表存在于索引[0],所以代码应该如下访问第一行数据表。 // 考虑到dt是DataTable的对象 dt.Rows [ 0 ]
请在下面找到代码,在数据表的第一行的所有列中插入相同的值,即11
foreach (DataColumn col in dt.Columns) { dt.Rows [ 0 ] [col.ColumnName] = 11; }快乐编码:)
dt.Rows [0] [ 0] =Hello World;
您可以使用列集合循环。 foreach (DataColumn列在 table.Columns中) { // 通过指定行[column]来访问每一行; }
I want to insert a value 11 in all the column of specific row. suppose I want to insert this value in first row like
dt.Tables[0].Rows[1]can anyone please provide the code?
解决方案 First of all, the first row of table is present at index [0] so the code should be as following to access first row of data table. // Considering that "dt" is an object of DataTable dt.Rows[0]Please find below the code to insert same value i.e. "11" in all columns of first row in datatable
foreach (DataColumn col in dt.Columns) { dt.Rows[0][col.ColumnName] = "11"; }Happy Coding :)
dt.Rows[0][0] = "Hello World";You can loop using columns collection. foreach(DataColumn column in table.Columns) { //access each row column by specifying row[column]; }更多推荐
如何在特定的数据行中插入公共值?
发布评论