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

How to find control inside Detail Template of RadTreeList in ItemCommand event of RadTreeList?

7 Answers 219 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Nikhil
Top achievements
Rank 1
Nikhil asked on 11 Sep 2012, 10:08 AM
Hello Telerik Team

How to find control inside Detail Template of RadTreeList in ItemCommand event of RadTreeList?
Finding on DataBound and ItemCreated will not work for requirement.

Thanks

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Sep 2012, 12:41 PM
Hi,

Try accessing the Detailtemplate as shown below.
aspx:
<telerik:RadTreeList runat="server" ID="RadTreeList1" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" onitemcommand="RadTreeList1_ItemCommand">
   <DetailTemplate>
      <asp:Button ID="Button1" CommandName="Select" runat="server" Text="select" />
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
   </DetailTemplate>
    <Columns>
     . . .
    </Columns>
</telerik:RadTreeList>
C#:
protected void RadTreeList1_ItemCommand(object sender, Telerik.Web.UI.TreeListCommandEventArgs e)
{
   if (e.CommandName == "Select")
   {
     TreeListDetailTemplateItem item = (TreeListDetailTemplateItem)e.Item;
     TextBox txt = (TextBox)item.FindControl("TextBox1");
   }
}

Thanks,
Shinu.
0
Nikhil
Top achievements
Rank 1
answered on 11 Sep 2012, 12:50 PM
Hi Shinu,

I already tried what you suggested. Giving me the below mentioned error for casting, since my
<asp:Button ID="Button1" CommandName="Select" runat="server" Text="select" />
is in TreeListTemplateColumn.

Thanks
 
0
Gopi
Top achievements
Rank 2
answered on 30 Dec 2014, 01:06 PM
Hi srinu,

   ContentPlaceHolder contentPage = Page.Master.FindControl("ContentPlaceHolder2") as ContentPlaceHolder;
            RadButton radbutton1 = (RadButton)contentPage.FindControl("RadButton1");

here I am not able to find rad

0
Gopi
Top achievements
Rank 2
answered on 30 Dec 2014, 01:10 PM
Hi srinu,

   ContentPlaceHolder contentPage = Page.Master.FindControl("ContentPlaceHolder2") as ContentPlaceHolder;
            RadButton radbutton1 = (RadButton)contentPage.FindControl("RadButton1");

here I am not able to findRadButton1
0
Konstantin Dikov
Telerik team
answered on 01 Jan 2015, 01:44 PM
Hi Gopi,

If your RadButton is placed in a TreeListItem, you should use the FindControl method from that item, because it could not be found from the ContentPlaceHolder.

If you need any further assistance with this, please elaborate on your exact scenario, so we can give an example, relevant to it.


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gopi
Top achievements
Rank 2
answered on 06 Jan 2015, 03:28 PM


ContentPlaceHolder contentPage = this.Page.Master.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
RadButton R = sender as RadButton;
RadButton radbutton1 = R.Parent.FindControl("RadButton1") as RadButton;


}
0
Konstantin Dikov
Telerik team
answered on 08 Jan 2015, 04:28 PM
Hello Gopi,

As I have explained in my previous posts, in order to get reference to a control placed within a a RadTreeList item, you should call the FindControl method from that item.

Once again, if you continue to have problems with this, please provide more details on your exact scenario and the requirement that you have.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeList
Asked by
Nikhil
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Nikhil
Top achievements
Rank 1
Gopi
Top achievements
Rank 2
Konstantin Dikov
Telerik team
Share this question
or