读书人

DataRow.GetChildRows (DataRelation)

发布时间: 2013-04-02 12:35:26 作者: rapoo

DataRow.GetChildRows (DataRelation)方法
dt有数据dr.GetChildRows("R").Length为什么是零呢 ,是不是我的关系“R”建立的有问题?
DataRow.GetChildRows (DataRelation)步骤
DataRow.GetChildRows (DataRelation)步骤
dr.GetChildRows("R").Length


public DataTable GetNextFormsList(int WorkflowID, int g_RSID)
{
DataTable dt = new DataTable();

DataSet ds = dal.GetNextFormsList(WorkflowID, g_RSID);
if (ds.Tables[0].Rows.Count > 0)
{
ds.Relations.Add("R", ds.Tables[0].Columns["thisId"], ds.Tables[0].Columns["wfid"],false);
dt = ds.Relations["R"].ParentTable;
dt.Columns.Add("branchIdList", typeof(System.Int32));
foreach (DataRow dr in dt.Rows)
{
string strBranchId = ",";
for (int i = 0; i < dr.GetChildRows("R").Length; i++)
{
strBranchId += dr.GetChildRows("R")[i]["branchId"].ToString();
}

dr["branchIdList"] = strBranchId.Substring(1, strBranchId.Length);
}
}

return dt;
}


[解决办法]
ds.Relations.Add("R", ds.Tables[0].Columns["thisId"], ds.Tables[0].Columns["wfid"],false);

你父列和子列都指定同一个DataTable?

读书人网 >asp.net

热点推荐