現在、重複する子ノードを返すradツリービュー。子ノードがすでに存在するかどうかを確認するために、どのように実装できますか。すでに存在する場合は、ループを追加して続行しないでください。ありがとうございました
private void BuildProjectTree(){
EntityCollection<ProjectEntity> collection = GetProjectData();
treProjects.Nodes.Clear();
ArrayList pgnodes = new ArrayList();
RadTreeNode pnode = null;
RadTreeNode snode = null;
//MembershipUserCollection membershipCollection = new MembershipUserCollection();
//membershipCollection = Membership.GetAllUsers();
foreach (ProjectEntity p in collection)
{
pnode = null;
foreach (RadTreeNode n in treProjects.GetAllNodes())
{
//bool nodeExist = false;
if (n.Text.Trim() == p.TeamLeader.Trim().ToUpper())
{
pnode = n;
break;
}
}
if (pnode != null)
{
snode = null;
foreach (RadTreeNode n in pnode.Nodes)
{
if (n.Value == p.ProjectSubGroup.ProjectGroup.Name)
{
snode = n;
break;
}
}
if (snode != null)
{
RadTreeNode projectnode = new RadTreeNode(p.ProjectTitle + " (" + p.ReferenceNumber + ")",
p.ProjectId.ToString(), BuildProjectNavigationUrl(p, false));
snode.Nodes.Add(projectnode);
}
}
else
{
RadTreeNode projectteamleadernode = new RadTreeNode(p.TeamLeader.Trim().ToUpper());
RadTreeNode projectgroupnode = new RadTreeNode(p.ProjectSubGroup.ProjectGroup.Name, String.Empty);
RadTreeNode projectnode = new RadTreeNode(p.ProjectTitle + " (" + p.ReferenceNumber + ")",
p.ProjectId.ToString(), BuildProjectNavigationUrl(p, false));
projectgroupnode.Nodes.Add(projectnode);
projectteamleadernode.Nodes.Add(projectgroupnode);
pgnodes.Add(projectteamleadernode);
}
}
foreach (RadTreeNode pg in pgnodes)
{
treProjects.Nodes.Add(pg);
}
//treProjects.ExpandAllNodes();
treProjects.CollapseAllNodes();
}