代码
public DataSet GetChildDepartmentsByUserId(Guid userId)
{
DataSet ds = new DataSet();
try
{
OrgChartDB.OrgChart_PermissionDataTable pdt = permissionTableAdapter.GetDataByUserId(userId);
for (int i = 0; i < pdt.Rows.Count; i++)
{
Guid deptId = pdt[i].DepartmentId;
OrgChartDB.OrgChart_DepartmentsDataTable ddtAllChildDepartments = departmentsTableAdapter.GetChildDepartmentByDepartmentId(pdt.Rows[0][0]);
ds.Tables.Add(ddtAllChildDepartments);
}
//OrgChartDB.OrgChart_DepartmentsDataTable ddtAllChildDepartments = departmentsTableAdapter.GetChildDepartmentByDepartmentId(pdt.Rows[0][0]);
return ds;
}
catch (Exception ex)
{
}
}
{
DataSet ds = new DataSet();
try
{
OrgChartDB.OrgChart_PermissionDataTable pdt = permissionTableAdapter.GetDataByUserId(userId);
for (int i = 0; i < pdt.Rows.Count; i++)
{
Guid deptId = pdt[i].DepartmentId;
OrgChartDB.OrgChart_DepartmentsDataTable ddtAllChildDepartments = departmentsTableAdapter.GetChildDepartmentByDepartmentId(pdt.Rows[0][0]);
ds.Tables.Add(ddtAllChildDepartments);
}
//OrgChartDB.OrgChart_DepartmentsDataTable ddtAllChildDepartments = departmentsTableAdapter.GetChildDepartmentByDepartmentId(pdt.Rows[0][0]);
return ds;
}
catch (Exception ex)
{
}
}
根据一个datatable中的一列值获取多个datatable并加入到dataset中。
注:此处pdt[i]返回PermissionDataRow能点出属性。
pdt.rows[0].[i]返回DataRow,点不出属性。