DataTable 操作,克隆,添加行

DataSet dt = rule.GetMyPayOrder(cid, uid);
int coutf = dt.Tables[0].Rows.Count;//父及數量
int couts = dt.Tables[1].Rows.Count;//子集數量
for (int i = 0; i < coutf; i++)
{

DataTable t=new DataTable();//子集
t = dt.Tables[1].Clone(); //克隆結構 Copy()複製全部

for (int j = 0; j < couts; j++)
{
if (dt.Tables[1].Rows[j]["PayID"].ToString().Equals(dt.Tables[0].Rows[i]["PayID"].ToString()))
{
t.ImportRow(dt.Tables[1].Rows[j]);
}
}
dt.Tables[0].Rows[i]["data"] = JsonHelper.ToJson(t, true);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章