笔记: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; } } }
通