象素
<asp:XmlDataSource runat="server" ID="TreeXml" EnableViewState="false" EnableCaching="false" />
<asp:TreeView ID="SelectTree" runat="server" DataSourceID="projectsTreeXml" AutoGenerateDataBindings="false">
<DataBindings>
<asp:TreeNodeBinding DataMember="A" TextField="DisplayID" ValueField="ID"/>
<asp:TreeNodeBinding DataMember="B" TextField="DisplayID" ValueField="ID" />
</DataBindings>
</asp:TreeView>
C# 代码
TreeXml.Data = getXMLString();
TreeXml.DataBind();
SelectCtrlTree.DataBind();
当我调试时,SelectTree 在调用 DataBind() 后成功填充了数据源,但 Nodes 元素为空,我认为应该没问题。
获取 getXMLString 返回字符串
<?xml version="1.0" encoding="UTF-8" ?>
- <Root>
- <A ID="3063" Name="All Initiatives" DisplayID="Enterprise">
<B ID="4911" Name="Closed - 2" DisplayID="Closed - 2"/>
- <A ID="17902" Name="Corporate Programs" DisplayID="Corporate">
- <A ID="25920" Name="In-flight Projects" DisplayID="In-flight">
<B ID="3688" Name="Cash Flow BI Project" DisplayID="CORP00712" />
</A>
</A>
</A>
</Root>
不知道为什么 UI 不显示任何内容