Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
How to use a WebDataTree custom template when you're binding data programmatically?
posted

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

 

 

 

Parents
  • 29417
    Offline posted

    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://ko.infragistics.com/support

     

Reply Children