62,074
社区成员
发帖
与我相关
我的任务
分享
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(@"xxxx.xml"));
if (ds != null)
{
foreach (DataRow function in ds.Tables[0].Rows)
{
if (string.IsNullOrEmpty(function["Value"].ToString())) continue;
TreeNode Root = new TreeNode();
Root.Text = function["Value"].ToString();
Root.Value = function["id"].ToString();
Root.Expanded = false;
DataRow[] childrows = ds.Tables[1].Select("MenuTitle_Id=" + function["MenuTitle_Id"]);
if (childrows.Length > 0)
{
foreach (DataRow chRow in childrows)
{
if (string.IsNullOrEmpty(chRow["ContentTitle"].ToString())) continue;
string selectedNode = Session["System_Selected_Node"] as string;
if (selectedNode == chRow["ContentTitle"].ToString())
Root.Expanded = true;
TreeNode temp = new TreeNode();
temp.Text = chRow["ContentTitle"].ToString();
temp.Value = chRow["ContentCode"].ToString();
temp.NavigateUrl = chRow["ContentPath"].ToString();
Root.ChildNodes.Add(temp);
}
}
TreeView1.Nodes.Add(Root);
}
}