Home - Forums-.NET - FlyTreeView (ASP.NET) - Setting up NodeTypes and ContentTemplates on the server side

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Setting up NodeTypes and ContentTemplates on the server side
Link Posted: 09-Jun-2010 07:51
I use the FlyTreeView control on a data driven eCommerce web site.  The items (nodes) of the FlyTreeView control are loaded programmatically on the server side which works fine.  I also need to be able to add text boxes, dropdowns, radio buttons or checkboxes to the treeview nodes similar to the Server Templates example (http://www.9rays.net/asp.net_2/treeview/Demo_ServerTemplates.aspx).  I see how to do this by setting up the <ContentTemplate> within the <NodeTypes>.  However, I need to do all this programmatically.  I need to be able to create the <ContentTemplate> within the <NodeTypes> from the codebehind on the server side.  Can this be done?

I hope I explained my problem adequately.

Thanks in advance.
Link Posted: 09-Jun-2010 10:39
When creating FlyNodeType instance programmatically,
you need to set nodeType.ContentTemplate which is ITemplate, which is not trivial from my point.

I think you would better consider using a predefined template, but have visible=false for those controls/parts that you do not use in a node, so they do not get rendered.

To do this, you can handle NodeDataBound event and adjust its node.Controls collection depending on some condition.

Anyway, you may still be interested in implementing ITemplate, but I didn't google out anything simple so far to do this.