TreeNode[] myNodes = new TreeNode[100];
for (int i = 0; i < myNodes.Length; i++)
{
myNodes[i] = new TreeNode();
}
for (int i = 0; i < dt.Rows.Count; i++)
{
int NodeId = (int)dt.Rows[i]["ModuleID"];
int MyParent = (int)dt.Rows[i]["Parent_int"];
if (MyParent != 0)
{
myNodes[NodeId].Text = dt.Rows[i]["Content_nva"].ToString();
myNodes[NodeId].NavigateUrl = dt.Rows[i]["Url_nva"].ToString().Trim();
myNodes[NodeId].ImageUrl = "~/Images/edit.gif";
myNodes[NodeId].Target = "main";
myNodes[MyParent].ChildNodes.Add(myNodes[NodeId]);
}
else
{
myNodes[NodeId].Text = dt.Rows[i]["Content_nva"].ToString();
myNodes[NodeId].SelectAction = TreeNodeSelectAction.None;
TreeView1.Nodes.Add(myNodes[NodeId]);
}
}