我使用XMLDataSource将XML数据绑定到treeview。它的工作方式,但是当节点和子节点的数量增加时,treenode扩展并显示iframe需要较长时间的 中的内容。如何减少在asp.net中填充树节点所花费的时间c#treeview?
<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>
在树状的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]);
}
。有没有可能使用XMLDatasource? – Mahantesh 2010-12-15 12:43:49
http://www.codegod.de/WebAppCodeGod/TreeView-ASP-NET-Populate-OnDemand-AID409.aspx – Cromathaar 2010-12-15 13:16:40
我阅读本教程,因为我修改了我的代码..但它不会触发OntreeItempopulate方法...你会根据懒惰绑定来修改我的代码吗? – Mahantesh 2010-12-15 13:22:28