Trying change an element in NodeTemplate

2 posts, 0 answers
  1. Tonyz289
    Tonyz289  avatar
    50 posts
    Member since:
    Jun 2011

    Posted 26 Jun 2013 Link to this post

    I am trying to change one element in the NodeTemplate of a Treeview and my code is not working. It executes fine but the change doesn't show up on the screen. What am I doing wrong?

    Here is the the code:
    protected void RadTreeView1_NodeDataBound (object sender, RadTreeNodeEventArgs e)
    {
        e.Node.ExpandMode = TreeNodeExpandMode.ServerSide;
        if (e.Node.Text == "Retailers")
        {
            RadTreeNode node = RadTreeView1.Nodes[0];
            HyperLink hyperLink = (HyperLink)node.FindControl ("HyperLink2");
            hyperLink.Visible = false;  // this what is want to do
            hyperLink.Text = "<span style=\"color: #BBBBBB\">X</span>"; // this is test to see that the Hyperlink Text changes
        // Neither of the above two lines produce the screen changes I am looking for
          }
    }

    Here is the defintion
    <telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="True" MultipleSelect="True"
        EnableViewState="true" ShowLineImages="False" EnableEmbeddedSkins="False" Skin="tree_2"
        OnNodeClick="RadTreeView1_NodeClick" OnNodeDataBound="RadTreeView1_NodeDataBound"
        OnClientNodeCollapsed="OnClientNodeCollapsed" OnClientNodeExpanded="OnClientNodeExpanded" OnClientLoad="onLoad">
        <NodeTemplate>
            <small>
                <asp:Label ID="lblnodeText" Text='<%#Eval("Title") %>' runat="server" /><asp:Label
                    ID="lblCatId" Text='<%#Eval("Id") %>' runat="server" Visible="false"></asp:Label><asp:Label
                        ID="lblisCustomer" Text='<%#Eval("isCustomer") %>' runat="server" Visible="false"></asp:Label><asp:Label
                            ID="Description" runat="server" Text='<%#Eval("description") %>' Visible="false" /><asp:HiddenField
                                ID="DescriptionVisible" runat="server" Value='<%#Eval("descriptionVisible") %>' />
            </small>
            <small>
    <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl=<%# "javascript:Popup_Window('category_detail','" + DataBinder.Eval(Container.DataItem, "id").ToString() + "')"%> style="text-decoration: none;"><span style="color: #BBBBBB">e</span></asp:HyperLink>
            </small>
        </NodeTemplate>
    </telerik:RadTreeView>
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 01 Jul 2013 Link to this post

    Hello Tony,

    I prepared a very simplified runnable page that demonstrates the desired approach. I can find the control in the node template and set its visibility property to false. Give it a try and let me know how it goes from your side.

    Regards,
    Kate
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top