I am having an .xml file with contents as a book with chapter , section and page tags.
Now how can i populate my treeview with the chapter name, section name, etc..
Also i should get the section when i select the chapter only.
I have tried but the plus(+) symbol which should be near the node is not present.
What should i do to get the proper treeview with proper indents and names.
Can anybody help me in Code.
Loading
Blocked AccountPosted Jan 7, 2008, 12:24 AM
Hi, Vanitha
I am posting the sample code for you. This is the tested code and it’s running. For this I have taken one XML file PageTitle.xml and I have put this file into the App_Data folder of the application.
<asp:XmlDataSource ID="PageDataSource" runat="server" XPath="/PageTitle" DataFile="~/App_Data/PageTitle.xml" />
<asp:TreeView ID="PageTreeView" runat="server" DataSourceID=" PageDataSource ">
<DataBindings>
<asp:TreeNodeBinding DataMember="Id" TextField="#InnerText" />
<asp:TreeNodeBinding DataMember="Tite" TextField="#InnerText" />
<asp:TreeNodeBinding DataMember="PageUrl" TextField="#InnerText" />
DataBindings>
asp:TreeView>
In the page load simply write.
protected void Page_Load(object sender, EventArgs e)
{
PageDataSource.XPath = "/PageTitle";
PageTreeView.DataBind();
}
I am also posting the xml file.
1
This
is my testing
mybook
/1/1.aspx
2
This
is my testing
mybook
/2/2.aspx
Hope, It will help you.Happy Coding!!
vanitha ManickamPosted Jan 4, 2008, 11:53 PM
Blocked AccountPosted Jan 4, 2008, 5:33 AM
Take the reference of this article posted in the c-sharpcorner.com, I am sending the URL of this article.
http://www.c-sharpcorner.com/UploadFile/mmehta/LoadingXmlInTreeView
11172005011544AM/LoadingXmlInTreeView.aspx
Hope, It will help you.
Happy Coding!!