Hi,
I have a treeview with Radcontextmenu, and itemplate contains other control..., when i make button_click that is a button into a itemplate.., i can't accessing control into itemplate..for example for set visible = false the controls that are inside the itemplate..
I have a treeview with Radcontextmenu, and itemplate contains other control..., when i make button_click that is a button into a itemplate.., i can't accessing control into itemplate..for example for set visible = false the controls that are inside the itemplate..
4 Answers, 1 is accepted
0

Rubihno
Top achievements
Rank 1
answered on 21 Oct 2008, 06:39 AM
What is the code for findcontrol into an itemtemplate?
0
Hi Rubihno,
You need to find the node and then search withing the Controls collection of the node:
I hope this helps.
All the best,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You need to find the node and then search withing the Controls collection of the node:
RadTreeNode node = RadTreeView1.FindNodeByText("My Node"); |
Button btn = (Button)node.FindControl("Button1"); |
btn.Text = "My new button text"; |
I hope this helps.
All the best,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Rubihno
Top achievements
Rank 1
answered on 21 Oct 2008, 10:24 AM
I tried but it does not work
I post my code:
In itemtemplate i have 2 button, when i click on button("test1" )would you like set visible = false the button ("test2"), for make this i must to findcontrol into an itemtemplate in event test1_Click
I post my code:
<telerik:RadTreeView ID="RdTreeView" runat="server" Skin="Sunset" |
Enabled="true" AllowNodeEditing="false" ExpandAnimation-Type="InElastic" |
EnableDragAndDrop="True" EnableDragAndDropBetweenNodes="True" |
MultipleSelect="True" SingleExpandPath="true" ShowLineImages="true" > |
<ContextMenus> |
<telerik:RadTreeViewContextMenu runat="server" ID="HelpDeskMenu" ClickToOpen="True" Skin="Vista"> |
<Items> |
<telerik:RadMenuItem Text="New" Visible="true"> |
<ItemTemplate> |
<asp:button ID="test1" runat="server" OnClick="test1_Click"/> |
<asp:Button ID="test2" runat="server" /> |
</ItemTemplate> |
</telerik:RadMenuItem> |
</Items> |
</telerik:RadTreeViewContextMenu> |
</ContextMenus> |
<CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation> |
<ExpandAnimation Duration="100"></ExpandAnimation> |
</telerik:RadTreeView> |
Protected Sub test1_Click(ByVal sender As Object, ByVal e As System.EventArgs) |
'code |
End Sub |
0

Shinu
Top achievements
Rank 2
answered on 22 Oct 2008, 07:31 AM
Hi Rubihno,
Try the following code snippet to achieve the desired scenario.
VB:
Regards
Shinu.
Try the following code snippet to achieve the desired scenario.
VB:
Protected Sub test1_Click(sender As Object, e As EventArgs) |
Dim btnTest1 As Button = DirectCast(sender, Button) |
Dim menuitem As RadMenuItem = DirectCast(btnTest1.NamingContainer, RadMenuItem) |
Dim btnTest2 As Button = DirectCast(menuitem.FindControl("test2"), Button) |
btnTest2.Visible = False |
End Sub |
Regards
Shinu.