1. the XML format is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Root name = "Digital rainwater" IMG = "image \ home.gif">
<Subroot name = "East China" IMG = "image \ resource_go.gif" nos = "1">
<Contont url = "1.html"> General info </contont>
<Contont url = "1.html"> person </contont>
<Contont url = "1.html"> nation </contont>
<Contont url = "1.html"> area </contont>
</Subroot>
<Subroot name = "North China" IMG = "image \ crm.gif" nos = "2">
<Contont url = "1.html"> original data </contont>
<Contont url = "1.html"> dairly Report </contont>
<Contont url = "1.html"> diary </contont>
<Contont url = "1.html"> relationship </contont>
</Subroot>
<Subroot name = "South China" IMG = "image \ salary.gif" nos = "3">
<Contont url = "1.html"> Dynamic Data </contont>
<Contont url = "1.html"> Information </contont>
</Subroot>
<Subroot name = "User Info" IMG = "image \ meeting.gif" nos = "4">
<Contont url = "1.html"> New User </contont>
<Contont url = "1.html"> registerd user </contont>
<Contont url = "1.html"> modify password </contont>
</Subroot>
</Root>
2: front-end:
<% @ Register Assembly = "system. Web. Extensions, version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35"
Namespace = "system. Web. UI" tagprefix = "asp" %>
<Asp: updatepanel id = "updatepanel1" runat = "server">
<Contenttemplate>
<Asp: treeview id = "treeview2" target = "mainframe" forecolor = "#215dc6" nodeindent = "5" runat = "server" showlines = "true" performanceid = "xmlperformance1" expanddepth =" 1 "onselectednodechanged =" treeview1_selectednodechanged "ondatabound =" treeview1_databound ">
<Nodestyle nodespacing = "0px" horizontalpadding = "5px" verticalpadding = "0"/>
<Rootnodestyle cssclass = "special"/>
<Parentnodestyle cssclass = "special"/>
<Selectednodestyle forecolor = "red"/>
</ASP: Treeview>
</Contenttemplate>
</ASP: updatepanel>
<Asp: xmldatasource id = "xmlperformance1" runat = "server" datafile = "~ /App_data/xmlfile. xml ">
</ASP: xmldatasource>
3. backend. CSCode:
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
Treeview2bind ();
}
}
Public void treeview2bind ()
{< br> treenodebinding root = new treenodebinding ();
root. datamember = "root";
root. valuefield = "name";
root. imageurlfield = "IMG";
// root. navigateurlfield = "url";
This. treeview2.databindings. add (Root);
treenodebinding subroot = new treenodebinding ();
subroot. datamember = "subroot";
subroot. valuefield = "nos";
subroot. textfield = "name";
subroot. imageurlfield = "IMG";
This. treeview2.databindings. add (subroot);
Treenodebinding content = new treenodebinding ();
Content. datamember = "contont ";
Content. valuefield = "# innertext ";
Content. navigateurlfield = "url ";
This. treeview2.databindings. Add (content );
// This. treeview1.showexpandcollapse = false;
}
1. the XML format is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Root name = "Digital rainwater" IMG = "image \ home.gif">
<Subroot name = "East China" IMG = "image \ resource_go.gif" nos = "1">
<Contont url = "1.html"> General info </contont>
<Contont url = "1.html"> person </contont>
<Contont url = "1.html"> nation </contont>
<Contont url = "1.html"> area </contont>
</Subroot>
<Subroot name = "North China" IMG = "image \ crm.gif" nos = "2">
<Contont url = "1.html"> original data </contont>
<Contont url = "1.html"> dairly Report </contont>
<Contont url = "1.html"> diary </contont>
<Contont url = "1.html"> relationship </contont>
</Subroot>
<Subroot name = "South China" IMG = "image \ salary.gif" nos = "3">
<Contont url = "1.html"> Dynamic Data </contont>
<Contont url = "1.html"> Information </contont>
</Subroot>
<Subroot name = "User Info" IMG = "image \ meeting.gif" nos = "4">
<Contont url = "1.html"> New User </contont>
<Contont url = "1.html"> registerd user </contont>
<Contont url = "1.html"> modify password </contont>
</Subroot>
</Root>
2: front-end:
<% @ Register Assembly = "system. Web. Extensions, version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35"
Namespace = "system. Web. UI" tagprefix = "asp" %>
<Asp: updatepanel id = "updatepanel1" runat = "server">
<Contenttemplate>
<Asp: treeview id = "treeview2" target = "mainframe" forecolor = "#215dc6" nodeindent = "5" runat = "server" showlines = "true" performanceid = "xmlperformance1" expanddepth =" 1 "onselectednodechanged =" treeview1_selectednodechanged "ondatabound =" treeview1_databound ">
<Nodestyle nodespacing = "0px" horizontalpadding = "5px" verticalpadding = "0"/>
<Rootnodestyle cssclass = "special"/>
<Parentnodestyle cssclass = "special"/>
<Selectednodestyle forecolor = "red"/>
</ASP: Treeview>
</Contenttemplate>
</ASP: updatepanel>
<Asp: xmldatasource id = "xmlperformance1" runat = "server" datafile = "~ /App_data/xmlfile. xml ">
</ASP: xmldatasource>
3. backend. CS code:
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
Treeview2bind ();
}
}
Public void treeview2bind ()
{
Treenodebinding root = new treenodebinding ();
Root. datamember = "root ";
Root. valuefield = "name ";
Root. imageurlfield = "IMG ";
// Root. navigateurlfield = "url ";
This. treeview2.databindings. Add (Root );
treenodebinding subroot = new treenodebinding ();
subroot. datamember = "subroot";
subroot. valuefield = "nos";
subroot. textfield = "name";
subroot. imageurlfield = "IMG";
This. treeview2.databindings. add (subroot);
treenodebinding content = new treenodebinding ();
content. datamember = "contont";
content. valuefield = "# innertext";
content. navigateurlfield = "url";
This. treeview2.databindings. add (content);
// This. treeview1.showexpandcollapse = false;
}