开发者

TreeNodeBinding show the innertext of all child nodes

开发者 https://www.devze.com 2023-02-19 03:53 出处:网络
A lot of time I spent for this situation. maybe someone can help me? I have a TreeView control on a ASP.Net page, and the data will be populate by DataBinding, using XMLDataSource.

A lot of time I spent for this situation. maybe someone can help me? I have a TreeView control on a ASP.Net page, and the data will be populate by DataBinding, using XMLDataSource.

<asp:TreeView id="treeview1" runat="server" DataSourc开发者_运维技巧eID="xmlDataSource1">
                <DataBindings>
                    <asp:TreeNodeBinding DataMember="All" TextField="#InnerText"   />
                    <asp:TreeNodeBinding DataMember="Categorie" TextField="#InnerText"   />
                    <asp:TreeNodeBinding DataMember="Question" TextField="#InnerText" ValueField="id" />
                </DataBindings>
</asp:TreeView>

The XML Data document is as follow:

<All>
  <ProjectName>
    Project A
    <Categorie>
      Cat A1
      <Question id="1">Q1</Question>
      <Question id="2">Q2</Question>
    </Categorie>
  </ProjectName>
</All>

When the page render, the output is that all nodes show also the child nodes element text. Output:

- Project ACatA1Q1Q2
    - Cat A1Q1Q2
        - Q1
        - Q2

Situation is: how to remove the child nodes text? So, the output must be:

- Project A
    - Cat A
        - Q1
        - Q2

It's like something wrong with the TreeNodeBinding. But changing the TextField to example "Value" doesn't work (empty node text).

i don't use XSLT transform file. The Xml will be given directly to the XmlDataSource.

Thank you.


I think you should use attributes instead of inner text:

<All>
  <Project Name="Project A">
    <Categorie Name="Cat A1">
      <Question id="1" Name="Q1"></Question>
    </Categorie>
  </Project>
</All>

and then bind to attributes

0

精彩评论

暂无评论...
验证码 换一张
取 消