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>
 
A

Alvin Bruney [MVP]

Your post went unanswered. Have you resolved this issue? If you still need
help, please post the original question with your request.
 
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>
 
A

Alvin Bruney [MVP]

you will need to rebuild your dll for the tree control again in order to
solve the problem. the build.bat file can help you rebuild the assembly
 
G

Guest

----- David Elliott wrote: ----

I am trying to use the TreeView Control that is part of th
WebControl
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 fro
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 th
the Page_Load and bind it to the control as a string, this works
jsut fine

Any help would be appreciated

Dav

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

public class WebForm1 : System.Web.UI.Pag

protected Microsoft.Web.UI.WebControls.TreeView MyTreeView

private void Page_Load(object sender, System.EventArgs e

MyTreeView.TreeNodeTypeSrc = @"state_city.xml"
MyTreeView.DataBind()



============================
The problem isn't necessarily with your XML file, rather the TreeView conrol may not be locating the file at all. Instead of setting TreeNodeTypeSrc with a literal (MyTreeView.TreeNodeTypeSrc = @"state_city.xml";), try this instead

MyTreeView.TreeNodeTypeSrc = Server.MapPath(@"state_city.xml")

I don't know why it's needed for this control, but the technique often works.
 

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

Top