目前,rad 树视图返回重复的子节点。我如何实现,检查子节点是否已经存在。如果已经存在,则不要添加并继续循环。谢谢
私人无效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();
}