码迷,mamicode.com
首页 > 其他好文 > 详细

DataTable 操作,克隆,添加行

时间:2016-01-27 18:59:03      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

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);
}

DataTable 操作,克隆,添加行

标签:

原文地址:http://www.cnblogs.com/lucoo/p/5163871.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!