您的位置:首页 > 其它

DataTable 操作,克隆,添加行

2016-01-27 17:02 357 查看
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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: