using
System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace GlistenCD.AdminUI.Uc
... {
public partial class LeftNavgationBar : System.Web.UI.UserControl
...{
private DataTable _navgationDataTable;
public DataTable NavgationDataTable
...{
set
...{
if (value != null)
...{
_navgationDataTable = value;
InitTree();
}
}
}
protected void Page_Init(object sender, EventArgs e)
...{
}
private void InitTree()
...{
int max = Int32.Parse(_navgationDataTable.Rows[0]["NavgationParent"].ToString());
for (int i = 0; i < _navgationDataTable.Rows.Count; i++)
...{
if (max < Int32.Parse(_navgationDataTable.Rows[i]["NavgationParent"].ToString()))
...{
max = Int32.Parse(_navgationDataTable.Rows[i]["NavgationParent"].ToString());
}
}
TreeNode rt = new TreeNode();
rt.Text = "Home";
AddChildNode(0, rt, max);
NavTree.Nodes.Add(rt);
}
private void AddChildNode(int parentID, TreeNode ParentNode,int max)
...{
for (int i = 0; i < _navgationDataTable.Rows.Count; i++)
...{
if (Int32.Parse(_navgationDataTable.Rows[i]["NavgationParent"].ToString()) == parentID)
...{
TreeNode tn = new TreeNode();
tn.Text = _navgationDataTable.Rows[i]["NavgationTitle"].ToString();
tn.Value = _navgationDataTable.Rows[i]["NavgationID"].ToString();
tn.NavigateUrl = _navgationDataTable.Rows[i]["NavgationUrl"].ToString();
tn.ToolTip = _navgationDataTable.Rows[i]["NavgationTip"].ToString();
tn.Expanded = false;
ParentNode.ChildNodes.Add(tn);
if (Int32.Parse(_navgationDataTable.Rows[i]["NavgationParent"].ToString()) < max)
AddChildNode(Int32.Parse(tn.Value), tn, max);
}
}
}
}
}
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace GlistenCD.AdminUI.Uc
... {
public partial class LeftNavgationBar : System.Web.UI.UserControl
...{
private DataTable _navgationDataTable;
public DataTable NavgationDataTable
...{
set
...{
if (value != null)
...{
_navgationDataTable = value;
InitTree();
}
}
}
protected void Page_Init(object sender, EventArgs e)
...{
}
private void InitTree()
...{
int max = Int32.Parse(_navgationDataTable.Rows[0]["NavgationParent"].ToString());
for (int i = 0; i < _navgationDataTable.Rows.Count; i++)
...{
if (max < Int32.Parse(_navgationDataTable.Rows[i]["NavgationParent"].ToString()))
...{
max = Int32.Parse(_navgationDataTable.Rows[i]["NavgationParent"].ToString());
}
}
TreeNode rt = new TreeNode();
rt.Text = "Home";
AddChildNode(0, rt, max);
NavTree.Nodes.Add(rt);
}
private void AddChildNode(int parentID, TreeNode ParentNode,int max)
...{
for (int i = 0; i < _navgationDataTable.Rows.Count; i++)
...{
if (Int32.Parse(_navgationDataTable.Rows[i]["NavgationParent"].ToString()) == parentID)
...{
TreeNode tn = new TreeNode();
tn.Text = _navgationDataTable.Rows[i]["NavgationTitle"].ToString();
tn.Value = _navgationDataTable.Rows[i]["NavgationID"].ToString();
tn.NavigateUrl = _navgationDataTable.Rows[i]["NavgationUrl"].ToString();
tn.ToolTip = _navgationDataTable.Rows[i]["NavgationTip"].ToString();
tn.Expanded = false;
ParentNode.ChildNodes.Add(tn);
if (Int32.Parse(_navgationDataTable.Rows[i]["NavgationParent"].ToString()) < max)
AddChildNode(Int32.Parse(tn.Value), tn, max);
}
}
}
}
}