This is a migrated thread and some comments may be shown as answers.

Trying change an element in NodeTemplate

1 Answer 40 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tonyz289
Top achievements
Rank 1
Tonyz289 asked on 26 Jun 2013, 01:37 PM
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>

1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 01 Jul 2013, 02:53 PM
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.
Tags
TreeView
Asked by
Tonyz289
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or