Asp.net Treeview bind xmldatasource

Source: Internet
Author: User

Front-end

<Asp: TreeView ID = "tvObject" runat = "server" performanceid = "xmlObject"
ShowCheckBoxes = "All" ExpandDepth = "1">
<DataBindings>
<Asp: TreeNodeBinding DataMember = "items" TextField = "Name" ValueField = "ID"/> <! -- Bind the attributes of the items node whose ID and Name are items nodes -->
<Asp: TreeNodeBinding DataMember = "item" TextField = "Name" ValueField = "ID"/> <! -- Bind the item node -->
<Asp: treenodebinding datamember = "NOTE" textfield = "name" valuefield = "ID"/> <! -- Bind the note node -->
<Asp: treenodebinding datamember = "root" textfield = "name" valuefield = "ID"/> <! -- Bind the root node -->
</DataBindings>
</Asp: TreeView>
<Asp: XmlDataSource ID = "xmlObject" runat = "server"> </asp: XmlDataSource>

The backend cs code is as follows:

In the page_load event:

If (! IsPostBack)
{
XmlObject. Data = EVE. Service. Model. PublicCode. getXml (); // get xml text

}

 

The xml format is as follows:

<Root ID = "All" Name = "All options">
<Note ID = "B" Name = "">
<Item ID = "egu" Name = "2">
<Items ID = "B egucc000" Name = "cccccccccccc"/>
</Item>
<Item ID = "eis" Name = "3">
<Items ID = "B egucc000" Name = "cccccccccccc"/>
</Item>
<Item ID = "eit" Name = "4">
<Items ID = "B egucc000" Name = "cccccccccccc"/>
</Item>
<Item ID = "eitc" Name = "5">
<Items ID = "B egucc000" Name = "cccccccccccc"/>
</Item>
<Item ID = "elc" Name = "6">
<Items ID = "B egucc000" Name = "cccccccccccc"/>
</Item>
<Item ID = "emc" Name = "7">
<Items ID = "B egucc000" Name = "cccccccccccc"/>
</Item>
<Item ID = "rtw" Name = "9">
<Items ID = "B egucc000" Name = "cccccccccccc"/>
</Item>
<Item ID = "ttsc" Name = "10">
<Items ID = "B egucc000" name = "cccccccccccc"/>
</Item>
<Item id = "egu" name = "11">
<Items ID = "B eguccnnn" name = "111111111"/>
</Item>
<Item id = "EIS" name = "69">
<Items ID = "B eguccnnn" name = "111111111"/>
</Item>
<Item id = "EIT" name = "89">
<Items ID = "B eguccnnn" name = "111111111"/>
</Item>
<Item id = "EITC" name = "SDF">
<Items ID = "B eguccnnn" name = "111111111"/>
</Item>
<Item ID = "elc" Name = "de">
<Items ID = "B eguccnnn" Name = "111111111"/>
</Item>
<Item ID = "emc" Name = "sdfwef">
<Items ID = "B eguccnnn" Name = "111111111"/>
</Item>
<Item ID = "rtw" Name = "asdfwe">
<Items ID = "B eguccnnn" Name = "111111111"/>
</Item>
<Item ID = "ttsc" Name = "gasdfwe">
<Items ID = "B eguccnnn" Name = "111111111"/>
</Item>
</Note>
<Note ID = "D" Name = "">
<Item ID = "eac" Name = "sdfwef">
<Items ID = "00000" Name = "00000000"/>
</Item>
<Item ID = "eic" Name = "8454">
<Items ID = "00000" Name = "00000000"/>
</Item>
<Item ID = "eiec" Name = "54514">
<Items ID = "00000" Name = "00000000"/>
</Item>
<Item ID = "elh" Name = "8784">
<Items ID = "00000" Name = "00000000"/>
</Item>
<Item ID = "esrc" Name = "63285">
<Items ID = "00000" Name = "00000000"/>
</Item>
</Note>
</Root>

 

If you are interested, you can try it...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.