C# , ASP.Net 3.5, Infragistics 11.1
I have a WebDataTree built without using a webhierarchicaldatasource and I would like to use a template for the nodes to change the way the image and text are displayed. I've used the smart tag to create a template, but I'm unable to use the <%# (Eval("Text")) %> a tags to display data because I'm not binding a data source. If I use a template similar to the one below, how to I set node values,imageurl, and text in C# code behind? I've tried accessing the controls to set values but can't seem to figure out how to get to them.
<ig:WebDataTree ID="wdtTree" runat="server" Height="600px" Width="400px" OnNodePopulate="wdtTree_TreeNodePopulate" EnableConnectorLines="True" OnNodeDropped="wdtTree_OnNodeDropped"> <DragDropSettings EnableDragDrop="True"> </DragDropSettings> <Templates> <ig:ItemTemplate ID="wdtTreeTemplate1" runat="server" TemplateID="NodesTemplate"> <Template> <asp:Image runat="server" ID="NodeImage" /> <asp:Label runat="server" ID="lblNodeText" Text=""></asp:Label> </Template> </ig:ItemTemplate> </Templates> </ig:WebDataTree>
Thanks,
Jon
Hello jpjosue ,
Another possible solution would be if you get them thought the PreRender event like this:
protected void wdtTree_PreRender(object sender, EventArgs e)
{
DataTreeNode item = wdtTree.Nodes[0];
item.EnsureTemplate();
Label label = (Label)item.FindControl("lblNodeText");
Image img = (Image)item.FindControl("NodeImage");
}
It would be more convenient to get them on an earlier stage for example in some of the raised events but if you’re manually adding the nodes not all of the events for the tree will fire(NodeBound, TreeNodePopulate, NodeAdded).
Let me know if you need further assistance with this issue.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Thanks, I'll try this later today. Essentially I'm just looking to be able to, for example, add additional icons to the right side of the node text that would be used as indicators, or to place a div around the left hand image (ImageURL) to to fix the left hand alignment of the Node Text where image widths are not the same(see below). Do I need a template for this, or is there a way to alter the default way a node is displayed?