SPlist按PID层级顺序导入datatable
public static System.Data.DataTable GetDataTable( int parentId, SPList list ,System.Data.DataTable dt, int ceng)
{
SPQuery query = new SPQuery();
query.Query = @"<Where>
<Eq>
<FieldRef Name='PID' />
<Value Type='Number'>" + parentId.ToString() + @"</Value>
</Eq>
</Where>" ;
SPListItemCollection items= list.GetItems(query);
foreach (SPListItem item in items)
{
string id = item.ID.ToString();
string taskName = ceng.ToString()+"#" +item["TaskNmae"].ToString();
string assignedTo = "DFDSFD" ;
//item["AssignedTo"].ToString().Substring(item["AssignedTo"].ToString().LastIndexOf("#") + 1);
string status = item["Status" ].ToString();
string pID = item["PID" ].ToString();
dt.Rows.Add(id,taskName, assignedTo, status, pID);
dt=GetDataTable(item.ID, list, dt,ceng+1);
}
return dt;
}
PID默认为0,层默认为1