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

8 posts, 0 answers
  1. Nikhil
    Nikhil avatar
    9 posts
    Member since:
    Oct 2011

    Posted 11 Sep 2012 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Sep 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nikhil
    Nikhil avatar
    9 posts
    Member since:
    Oct 2011

    Posted 11 Sep 2012 Link to this post

    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
     
  5. Gopi
    Gopi avatar
    15 posts
    Member since:
    Jan 2013

    Posted 30 Dec 2014 in reply to Nikhil Link to this post

    Hi srinu,

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

    here I am not able to find rad

  6. Gopi
    Gopi avatar
    15 posts
    Member since:
    Jan 2013

    Posted 30 Dec 2014 in reply to Nikhil Link to this post

    Hi srinu,

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

    here I am not able to findRadButton1
  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 01 Jan 2015 Link to this post

    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.

     
  8. Gopi
    Gopi avatar
    15 posts
    Member since:
    Jan 2013

    Posted 06 Jan 2015 in reply to Konstantin Dikov Link to this post



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


    }
  9. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 08 Jan 2015 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017