Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何减少在asp.net c#treeview中填充树节点所需的时间?_C#_Asp.net - Fatal编程技术网

如何减少在asp.net c#treeview中填充树节点所需的时间?

如何减少在asp.net c#treeview中填充树节点所需的时间?,c#,asp.net,C#,Asp.net,我正在使用XMLDataSource将XML数据绑定到treeview。它的工作时间很短,但当节点和子节点的数量增加时,树节点将展开并显示其中的内容 iframe需要更多的时间 <asp:TreeView ID="TreeView1" OnSelectedNodeChanged = "OnClick" runat="server" ExpandDepth="0" ShowExpandCollapse="true" ForeColor="Red"

我正在使用XMLDataSource将XML数据绑定到treeview。它的工作时间很短,但当节点和子节点的数量增加时,树节点将展开并显示其中的内容 iframe需要更多的时间

<asp:TreeView ID="TreeView1"  OnSelectedNodeChanged = "OnClick" runat="server" 
                    ExpandDepth="0"  ShowExpandCollapse="true" ForeColor="Red" Font-Underline = "false" 
                    ondatabinding="TreeView1_DataBinding" CollapseImageUrl = "Resources/TocColapse.bmp" ExpandImageUrl = "Resources/TocParent.bmp" Font-Names="Arial"   >
                    <SelectedNodeStyle Font-Underline="false" BackColor="White" ForeColor="#0483e0" />
                    <NodeStyle Font-Size="11pt" ForeColor="white" HorizontalPadding="5px"
                        NodeSpacing="0px" VerticalPadding="0px" Font-Underline = "false" />
                    <ParentNodeStyle ForeColor="#0483e0" Font-Underline = "false" />
                    <LeafNodeStyle ForeColor="#0483e0" Font-Underline = "false" ImageUrl = "Resources/TocChild.bmp"  />

                </asp:TreeView>
                <asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="/*/*" EnableCaching = "false" ></asp:XmlDataSource>

在treeview的OnDataBinding事件中,我实现了以下代码:

 TreeNodeBinding[] TreeNode = new TreeNodeBinding[Count];
        for (int i = 0; i < Count; i++)
        {
            TreeNode[i] = new TreeNodeBinding();
            TreeNode[i].DataMember = TableOfContents[i].GetElementName();
            TreeNode[i].TextField = TableOfContents[i].GetFirstAttributeName();
            TreeNode[i].ValueField = TableOfContents[i].GetSecondAttributeName();
            // TreeNode[i].Target = "contentFrame";
            TreeView1.DataBindings.Add(TreeNode[i]);
        }
TreeNodeBinding[]TreeNode=新的TreeNodeBinding[Count];
for(int i=0;i
如何将EnableCaching设置为“true”


另外,您确定需要显示整个xml吗?您可以为用户提供一些过滤,以减少显示的xml的大小。

当然可以。看看延迟加载。

尝试按需填充


在客户端加载treeview花费了很长时间时,我使用了按需填充。

如果我将EnableCaching设置为“true”或false,则没有任何区别。是否可以使用PopulateOndemand标志进行填充。。但我不知道如何在XMLDatasource和TreeView中使用PopulateOndemand,我为树视图提供了单一扩展功能。只有一个节点将填充..如果我使用OnItemPopulate和populateOndemand=true。可以使用XMLDatasource吗?我阅读本教程是因为我修改了我的代码。。但它不会触发OnTereeItemPopulate方法。。。你会修改我的代码吗