PageLoad上的ASP:TreeView不会展开指定的节点

时间:2019-03-08 08:32:46

标签: asp.net .net-4.0 treeview

我正在向页面传递许多参数。在代码中,参数用于首先定位父节点和随后的子节点。在表单加载事件中,它可以正常工作,并且能够找到父节点和子节点。

if (!IsPostBack)
{
    /*OnSelectedNodeChanged="trvFolders_SelectedNodeChanged" OnTreeNodeExpanded="trvFolders_SelectedNodeExpanded"*/
    if (!string.IsNullOrEmpty(Request.QueryString["Location"]) && !string.IsNullOrEmpty(Request.QueryString["Folder"]))
    {
        string MappedPath = "yyyyyyy";
        string UrlPath = "xxxxxxxxxxxxx";
        PAL004.DocumentLibraryFolders TopLocation;
        string Folder = Request.QueryString["Folder"];
        string Location = Request.QueryString["Location"];
        Enum.TryParse(Location,out TopLocation);

        LoadFolders(trvFolders);

        if (TopLocation != PAL004.DocumentLibraryFolders.None)
        {
            PAL004.DocumentLibraryFolders DocumentLocation;
            LibraryDocument LocatedDocument = Documents.Where(doc => doc.ContextID.ToString() == Location).ToList().First();

            Enum.TryParse(LocatedDocument.ContextID.ToString(), out DocumentLocation);

            if (DocumentLocation == TopLocation)
            {
                TreeNode tNode = trvFolders.FindNode(LocatedDocument.ID.ToString());
                PopulateSubDirectoriesL1(tNode);
                //tNode.Select();
                //tNode.ChildNodes[0].Expand();
                //tNode.Expand();
                //TreeNode sNode = trvFolders.SelectedNode;
                //sNode.Expand();
                string FindNodePathValue = LocatedDocument.ID + "/" + LocatedDocument.Link.Replace(MappedPath, UrlPath) + "\\" + Folder;
                TreeNode cNode = trvFolders.FindNode(FindNodePathValue);
                trvFolders.DataBind();
                cNode.Select();
                cNode.Expand();
                trvFolders_SelectedNodeChanged(trvFolders, EventArgs.Empty);
            }
            //Node = trvFolders.FindNode()
        }

    }
    else
    {
        LoadFolders(trvFolders);
    }
    trvFolders.CollapseAll();

    //TreeNode NodeFind = trvFolders.FindNode("21");
    //NodeFind.ExpandAll();

    BasePage bp = new BasePage();
    btnAdmin.Visible = bp.CheckAccess(pathparameter, AccessControl.AccessType.Any);
}
else
{
    trvFolders_SelectedNodeChanged(trvFolders, new EventArgs());
}

}

为什么不展开页面上的树状视图?

Asp TreeView OnTreeNodeExpanded event prevents treeview from expanding指出这可能是由于值和valuepath值不可用引起的。事实并非如此。所有节点都有值和值路径。我可以找到子节点并将其展开,但它不会显示在页面上。

TreeView - Node not expanding被重新分配到Crownwood库

TreeView expanding wrong node节点值和值路径是唯一的,并且已成功定位。

0 个答案:

没有答案