DataRow.GetChildRows (DataRelation)方法
dt有数据dr.GetChildRows("R").Length为什么是零呢 ,是不是我的关系“R”建立的有问题?
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;
}