WebControls TreeView Error

D

David Elliott

I am trying to use the TreeView Control that is part of the WebControls
package from Microsoft.

I was getting this error:
Exception Details: System.Xml.XmlException: The data at the
root level is invalid. Line 1, position 1.

I then set the permission for the file and then started getting:
Exception Details: System.Exception: The XML loaded from
TreeNodeSrc=state_city.xml, TreeNodeXslSrc= did not contain
the required outer <TREENODES> container.

The XML file clearly has it. If I cut and paste the XML file into the
the Page_Load and bind it to the control as a string, this works
jsut fine.

Any help would be appreciated.

Dave

===================

public class WebForm1 : System.Web.UI.Page
{
protected Microsoft.Web.UI.WebControls.TreeView MyTreeView;

private void Page_Load(object sender, System.EventArgs e)
{
MyTreeView.TreeNodeTypeSrc = @"state_city.xml";
MyTreeView.DataBind();
}
}


<?xml version="1.0" ?>
<TREENODES>
<treenode Text="Michigan">
<treenode Text="Detroit" />
<treenode Text="Farmington" />
<treenode Text="Southfield" />
</treenode>
<treenode Text="Washington">
<treenode Text="Bellevue" />
<treenode Text="Redmond" />
<treenode Text="Woodinville" />
</treenode>
</TREENODES>
 
O

olevchuk

// -- Try this

TreeNode nodeTop = new TreeNode();

nodeTop.Text = "My Root Node";
nodeTop.ExpandedImageUrl = "/webctrl_client/1_0/images/root.gif" ;

Treeview1.Nodes.Add(nodeTop);

Treeview1.Nodes[0].Expanded = true;
Treeview1.Nodes[0].TreeNodeSrc
Server.MapPath("./state_city.xml");
Treeview1.Nodes[0].Databind()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top