473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

[ASP.net 2] TreeView & XmlDocument ?

Ryo
Hello !

I have an XmlDocument in memory and I want to put this document as
datasource of my treeview.
How to do this ?
Thanks.
Nov 19 '05 #1
2 3324
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.

Nov 19 '05 #2
Ryo
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.


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: serge calderara | last post by:
dear all, Is there an easy way to bind a treeview control with an XML object as datasource? In a similar way as the dataset is doing, and build columns accroding to XML node, I could imagine a...
1
by: Casper JH Erasmus | last post by:
How do I save the contents of a TreeView to a XML Document?
2
by: Craig | last post by:
Is there a way to "tie" or "bind" an XmlDocument to a treeView, so the changes in the treeView can automatically be reflected in the XmlDocument object? (Like DataSource for a ListBox) If not,...
12
by: Alex D. | last post by:
How can I stop asp.net from rendering XHTML istead of HTML? My javascripts are rendering wrong because of that. It is rendering &amp; to clients instead of &. Any help? Thanks, Alejandro.
2
by: C. A. Kelly | last post by:
I have seen lots of posts for populating a treeview from a XML file but haven't been able to find/figure out how to go from a treeview to XML.
2
by: Simon Rigby | last post by:
Hi folks, A bizarre problem I am having. I have a treeview which is bound to an XmlDataSource. The XMLDataSource.Data property is set to the result of a function that generates an XML...
0
by: lewis76 | last post by:
I have figured out how to populate a treeview with an xml file however I just can't for the life of me get this formatting of the nodes right. Here's where I'm at: <Season>...
0
by: Kenichi777 | last post by:
I have a treeview wich populates from a xml file - it all works dandy... but i am not satisfied... this is my xml file... <?xml version="1.0" encoding="utf-8"?> <ProductsList> <Category...
0
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.