473,395 Members | 1,456 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,395 software developers and data experts.

Populate TreeView From XML

This is the all code. Very simple and short. I need to
populate a treeView in aspx page (web form) from XML file.
I get en completion error:No overload for
method 'TreeNode' takes '1' arguments .

using System;
using System.Web.UI.WebControls;
using Microsoft.Web.UI.WebControls;
using System.Xml;

namespace PopulateTVTest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected Microsoft.Web.UI.WebControls.TreeView treeView1;
protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler
(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs
e)
{

// SECTION 1. Create a DOM Document and load the XML data
into it.
XmlDocument dom = new XmlDocument();
dom.Load("D:/Dirs_3.xml");
// SECTION 2. Initialize the TreeView control.
treeView1.Nodes.Clear();
treeView1.Nodes.Add(new TreeNode
(dom.DocumentElement.Name));--> error: No overload for
method 'TreeNode' takes '1' arguments
TreeNode tNode = new TreeNode();
tNode = treeView1.Nodes[0];
// SECTION 3. Populate the TreeView with the DOM nodes.
AddNode(dom.DocumentElement, tNode);
//treeView1.ExpandAll();
}

private void AddNode(XmlNode inXmlNode, TreeNode
inTreeNode)
{
XmlNode xNode;
TreeNode tNode;
XmlNodeList nodeList;
int i;

// Loop through the XML nodes until the leaf is reached.
// Add the nodes to the TreeView during the looping
process.
if (inXmlNode.HasChildNodes)
{
nodeList = inXmlNode.ChildNodes;
for(i = 0; i<=nodeList.Count - 1; i++)
{
xNode = inXmlNode.ChildNodes[i];
inTreeNode.Nodes.Add(new TreeNode(xNode.Name)); --> error:
No overload for method 'TreeNode' takes '1' arguments

tNode = inTreeNode.Nodes[i];
AddNode(xNode, tNode);
}
}
else
{
// Here you need to pull the data from the XmlNode based
on the
// type of node, whether attribute values are required,
and so forth.
inTreeNode.Text = (inXmlNode.OuterXml).Trim();
}
}
}
}
thank you very much!
Nov 16 '05 #1
0 1453

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

Similar topics

0
by: T.H.M | last post by:
This is the all code. Very simple and short. I need to populate a treeView in aspx page (web form) from XML file. I get en completion error:No overload for method 'TreeNode' takes '1' arguments ....
4
by: Mike | last post by:
how can i populate a treeview from a database? websites with examples would help.
3
by: Jan Wrage | last post by:
Hi! I would like to implement a treeview in my existing application. It should show my entire Active-Directory structure, i.e. all Groups, Containers and OUs. Could somebody help me with...
9
by: Marina | last post by:
Hello! I have a database with some customers. Each one of them has 3 other customers under him etc. (something like an MLM system). Now, I want to create a treeview with this. Eg. C1 C11...
2
by: Dave Wurtz | last post by:
All, I have a treeview on my form that has a lot of nodes on it. I would like to populate this treeview on another thread so my form will still paint while it is being populated. I have...
1
by: john wright | last post by:
I have my code done to populate a treeview, but when I move it to the backgroundworker I get an error "Action being performed on this control is being called from the wrong thread. Marshal to the...
6
by: Beginner | last post by:
Hi, I'm trying to populate a TreeView from an existing and filled in ListView (lvwBuild). lvwBuild is a basic two column listview which can have any number of rows. I would like the first...
0
by: Patrick | last post by:
Hi, Im trying to populate my treeview control onmy webpage with the information that is stored in a xml file, but i cant seem to find any good references about it. The xml file looks like this. ...
0
by: xmail123 | last post by:
How to populate a treeview from a dataset I am very new to C#. I need to create a Windows form that will read a SQL table and populate a treeview. I can connect to the DB, create the...
0
by: Dennis Francek | last post by:
Hello I have populated a treeview from my dataset and by clicking in the treeview i want to get the corresponding table shown in a datagridview. Ive managed this by looking at each DataRow and...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.