日期:2014-05-17 浏览次数:20886 次
public DataTable GetList(int PId)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select Id,Title,ParentId,ClassList,ClassLayer,SortId,PageUrl,KindId from dt_Channel");
DataSet ds = DbHelperOleDb.Query(strSql.ToString());
DataTable oldData = ds.Tables[0] as DataTable;
if (oldData == null)
{
return null;
}
//复制结构
DataTable newData = oldData.Clone();
//组合成DAGATABLE
GetChannelChild(oldData, newData, PId);
return newData;
}
private void GetChannelChild(DataTable oldData, DataTable newData, int PId)
{
DataRow[] dr = oldData.Select("ParentId=" + PId);
for (int i = 0; i < dr.Length; i++)
{
//添加一行数据
DataRow row = newData.NewRow();
row["Id"] = int.Parse(dr[i]["Id"].ToString());
row["Title"] = dr[i]["Title"].ToString();
row["ParentId"] = int.Parse(dr[i]["ParentId"].ToString());
row["ClassList"] = dr[i]["ClassList"].ToString();
row["ClassLayer"] = int.Parse(dr[i]["C