Had a quick look at Linq2Umbraco, but not entirly sure how it will help I am quite new to .Net.
I have a TreeView control added to the .ascx file and I am trying to populate it using the umbraco content tree. My control requires that the user is able to choose a node form within the content tree.
That helped alot, in the end I managed to get my recursive function working so that the whole content tree could be stepped and then bound to a tree view.
Bind Node children to Treeview
Hi All
I am trying to write a user control that has access to the content tree. Does any one have a good way of binding the content tree to a treeview ?
I have tried writing a recursive function to walk the tree but im not getting any where any help would be great!
L
Hi L,
How about using Linq2Umbraco?
Video tutorial:
http://vimeo.com/9788833
HTH.
Sincere regards,
Eduardo Macho
Hey Thanks Eduardo,
Had a quick look at Linq2Umbraco, but not entirly sure how it will help I am quite new to .Net.
I have a TreeView control added to the .ascx file and I am trying to populate it using the umbraco content tree. My control requires that the user is able to choose a node form within the content tree.
any suggestions?
Thanks
L
Hi L,
Binding the content tree to a treeview
I presume your ascx file contains a line of code like the next.
<asp:TreeView ID="TreeView1"
SkinId="Bookstoree
ExpandDepth="3"
MaxDataBindDepth="3"
runat="server" />
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/navigation/treeview.aspx
1. We need to retrieve all the nodes in the Umbraco Content XML and format them.
This can be done using a special function within Umbraco Business Logic.
umbraco.presentation.nodeFactory.Node node = new umbraco.presentation.nodeFactory.Node(-1);
umbraco.presentation.nodeFactory.Nodes childrenNodes = node.Children;
2. Bind on the Page_Load event of the control all the data from the Umbraco Content XML to the tree control.
protected void Page_Load(object sender, EventArgs e)
{
umbraco.presentation.nodeFactory.Node node = new umbraco.presentation.nodeFactory.Node(-1);
umbraco.presentation.nodeFactory.Nodes childrenNodes = node.Children;
foreach (umbraco.presentation.nodeFactory.Node n in childrenNodes)
{
Treeview1.Nodes.Add(new TreeNode(n.Name, n.Id.ToString()));
Treeview1.DataBind();
}
}
HTH.
Sincere regards,
Eduardo
Thanks Eduardo,
That helped alot, in the end I managed to get my recursive function working so that the whole content tree could be stepped and then bound to a tree view.
thanks again for your help/
Hi Lachlan,
Glad to hear from you. You are Welcome!.
If my answer helped you, please mark it as the solution.
Sincere regards,
Eduardo Macho
is working on a reply...