Hi !
To do what you said, I do this:
// Simulate the XmlDocument created in memory
XmlDocument xmd = new XmlDocument();
xmd.Load(Server.MapPath("~/test.xml"));
XmlDataSource xds = new XmlDataSource();
xds.Data = xmd.InnerXml;
MyTreeView.DataSource = xds;
MyTreeView.DataBind();
This work, but there is a little problem, in my XML file I have an attribute
called 'Url' and to use this field I have this declaration with my TreeView:
<asp:TreeNodeBinding DataMember="Link" ValueField="ID" TextField="Name"
NavigateUrlField="Url" />
And finally, on the TreeView created, I haven't the link.
I can't understand why I have this problem because if I do that instead of
simulate the XmlDocument in memory:
XmlDataSource xds = new XmlDataSource();
xds.DataFile = Server.MapPath("~/test.xml");
MyTreeView.DataSource = xds;
MyTreeView.DataBind();
This work pretty fine and I have the link.
?_?
"Brock Allen" wrote:
The TreeView uses a XmlDataSource, so what you need to do is set the XML
into the XmlDataSource. Unfortunately it doesn't accept a XmlReader or a
XmlNode and only allows you to set int a string. But it works.
-Brock
DevelopMentor
http://staff.develop.com/ballen
Hello !
I have an XmlDocument in memory and I want to put this document as
datasource of my treeview.
How to do this ?
Thanks.