编程语言
首页 > 编程语言> > C#Datatable 根据某字段 自动复制该行

C#Datatable 根据某字段 自动复制该行

作者:互联网

/// <summary>
/// 根据Datatable某字段数量自动复制该行查询
/// </summary>
/// <param name="dt">数据源</param>
/// <param name="Ifileid">某字段(数量值)</param>
private static void UpdatateDt(DataTable dt, string Ifileid)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
var row = dt.Rows[i];
int Ifileid= int.Parse(row["Ifileid"].ToString());
for (int j = 0; j < Ifileid- 1; j++)
{
DataRow newRow = dt.NewRow();
newRow.ItemArray = row.ItemArray;
dt.Rows.InsertAt(newRow, i + 1);
}
i += Ifileid- 1;
}
}
}

标签:某字段,C#,int,Rows,Ifileid,dt,Datatable,row
来源: https://www.cnblogs.com/jiaozai891/p/16404408.html