Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Panelbar > Not able to access the controls inside itemtemplate radpanelbar
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not able to access the controls inside itemtemplate radpanelbar

Feed from this thread
  • Guru avatar

    Posted on Jan 2, 2007 (permalink)

    Hi,
       I am using a radpanelbar, in itemtemplate i have used some tables, divs ,panels but i am not abloe to access them thru thr id or name using javascript and c#'s FindControl() finction. Please help me out. I am attaching a code below.

     I have a splitter, in tat rapane , in radpane i have radpanelbar inside that i have used itemtemplate nad inside itemtemplate a panel. I am sending the code of only radpanelbar. Please see to it.

    <radspl:RadSplitter ID="RadSplitter1" runat="server" Orientation="Horizontal" Skin="Default"

    Height="100%" Width="100%">

    <radspl:RadPane ID="a" runat="server"></radspl:RadPane>

    <radspl:RadSplitBar ID="Splitter1" runat="server" CollapseMode="Forward" />

    <radspl:RadPane runat="server" ID="CheckList" MinHeight="200">

    <radP:RadPanelbar ID="RadPanelBar1" runat="server" Skin="centerBodyPanelSkin" SkinsPath="~/RadControls/Panelbar/skins">

    <Items>

    <radP:RadPanelItem Text="A" runat="server">

    <Items>

    <radP:RadPanelItem runat="server">

    <ItemTemplate>

    </ItemTemplate>

    </radP:RadPanelItem>

    </Items>

    </radP:RadPanelItem>

    <radP:RadPanelItem Text="P" runat="server">

    <Items>

    <radP:RadPanelItem runat="server">

    <ItemTemplate>

    </ItemTemplate>

    </radP:RadPanelItem>

    </Items>

    </radP:RadPanelItem>

    <radP:RadPanelItem Text="Specific" runat="server">

    <Items>

    <radP:RadPanelItem runat="server">

    <ItemTemplate>

    <asp:Panel runat="server" ID="panel2" >

    <div style="float: left" runat="server" id="main">

    <div id="Div3" runat="server" style="margin-top: 55px; margin-left: 9px">

    <asp:Image ID="ImageButton6" runat="server" ImageUrl="~/Images/CorporateGreen/arrow_right.gif"

    />

    </div>

    <div id="Div4" visible="false" runat="server" style="margin-top: 12px; margin-left: 4px">

    <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/Images/CorporateGreen/arrow_down.gif"

    OnClientClick="cls();" />

    </div>

    <div id="Div1" runat="server" style="float: left; margin-top: 12px; margin-left: 4px">

    <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/Images/CorporateGreen/arrow_right.gif" OnClientClick="opn()" />

    </div>

    </div></asp:Panel>

    <asp:Table runat="server" ID="ATbl" CssClass="gridtable">

    <asp:TableHeaderRow CssClass="gridtable_header">

    <%-- <asp:TableCell Text=""></asp:TableCell>--%>

    <asp:TableCell Text="Title"></asp:TableCell>

    <asp:TableCell Text="SCheck"></asp:TableCell>

    <asp:TableCell Text="MCheck"></asp:TableCell>

    <asp:TableCell Text="RCode"></asp:TableCell>

    <asp:TableCell Text="Reason"></asp:TableCell>

    </asp:TableHeaderRow>

    <asp:TableRow>

    <%-- <asp:TableCell Text="">

    <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/CorporateGreen/arrow_right.gif" /></asp:TableCell>

    --%>

    <asp:TableCell Text="Range"></asp:TableCell>

    <asp:TableCell Text=""></asp:TableCell>

    <asp:TableCell Text="">

    </asp:TableCell>

    <asp:TableCell Text="">

    <asp:DropDownList ID="DropDownList3" runat="server" CssClass="dropdown">

    </asp:DropDownList>

    </asp:TableCell>

    <asp:TableCell Text="">

    <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="15px"></asp:TextBox>

    </asp:TableCell>

    </asp:TableRow>

    <asp:TableRow>

    <%--<asp:TableCell Text="">

    <div id="Div1" runat="server">

    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/CorporateGreen/arrow_right.gif"

    OnClick="a" />

    </div>

    <div id="Div5" visible="false" runat="server">

    <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/Images/CorporateGreen/arrow_down.gif"

    OnClick="b" />

    </div>

    </asp:TableCell>--%>

    <asp:TableCell Text="Seating Capacity"></asp:TableCell>

    <asp:TableCell Text=""></asp:TableCell>

    <asp:TableCell Text="">

    </asp:TableCell>

    <asp:TableCell Text="">

    <asp:DropDownList ID="DropDownList5" runat="server" CssClass="dropdown">

    </asp:DropDownList></asp:TableCell>

    <asp:TableCell Text="">

    <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Height="15px"></asp:TextBox>

    </asp:TableCell>

    </asp:TableRow>

    </asp:Table>

    <div>

    </div>

    </ItemTemplate>

    </radP:RadPanelItem>

    </Items>

    </radP:RadPanelItem>

    </Items>

    </radP:RadPanelbar>

    </radspl:RadPane>

    </radspl:RadSplitter>

    Thanks

    Regards
    Gururaj


  • Krasimir Evtimov Krasimir Evtimov admin's avatar

    Posted on Jan 3, 2007 (permalink)

    Hello Gururaj,

    FindControl searches only in the current Naming container, as documented in the MSDN. So, since both the RadPanelbar class and the RadPanelItem are naming containers, you need to search inside the RadPanelItem and not in the RadPanelbar itself.

    Sincerely yours,
    Krasimir Evtimov
    the telerik team

  • Guru avatar

    Posted on Jan 3, 2007 (permalink)

    Hi,

       Thanks. Can you send me an example please.

    Thanks

    Regards
    Gururaj

  • Rumen Rumen admin's avatar

    Posted on Jan 3, 2007 (permalink)

    Hello Gururaj,

    FindControl is a generic ASP.NET framework method, documented in MSDN.
    http://msdn2.microsoft.com/en-us/library/486wc64h.aspx

    Greetings,
    Rumen Stankov (MCSD.NET)
    the telerik team

  • Jim avatar

    Posted on Sep 17, 2009 (permalink)

    Would it really have been that hard for you to post an example?

    Mr. MCSD.NET

  • Posted on Sep 18, 2009 (permalink)

    Hello Jim,

    Checkout the following example which shows how to access the controls placed in ItemTemplate of PanelBarItem.

    ASPX:
     
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server"
        <Items> 
            <telerik:RadPanelItem runat="server" Text="Catelog" Value="Catelog"
                <ItemTemplate> 
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
                </ItemTemplate> 
                <Items> 
                    <telerik:RadPanelItem runat="server" Text="Child1"
                    <ItemTemplate> 
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
                    </ItemTemplate> 
                    </telerik:RadPanelItem> 
                    <telerik:RadPanelItem runat="server" Text="Child2"
                    </telerik:RadPanelItem> 
                </Items> 
            </telerik:RadPanelItem>                     
        </Items> 
    </telerik:RadPanelBar> 

    CS:
     
    protected void Button1_Click(object sender, EventArgs e) 
        // Get reference to the panelbaritem which contains control 
        RadPanelItem panelItem1 = (RadPanelItem)RadPanelBar1.FindItemByText("Catelog"); 
        Label Lbl = (Label)panelItem1.FindControl("Label1"); // Use FindControl method to get the control 
        Lbl.Text = "Text Changed"// Set property of control from code 
     
        // Access the panelbaritem which contains control 
        RadPanelItem panelItem2 = (RadPanelItem)RadPanelBar1.FindItemByText("Child1"); 
        TextBox txtBox = (TextBox)panelItem2.FindControl("TextBox1"); 
        txtBox.Text = "Text Changed"

    Also checkout the following documentation for more details:
    Accessing Controls Inside Templates

    -Shinu.

  • Miguel avatar

    Posted on May 2, 2011 (permalink)

    Hi Jim, I am enclosing a very interesting code for you to solve this problesm for ever.


    First it is a class I have done:

     

     

     

     

    namespace GenLib.Comun 
    {
        public class CtrlFinderPrv 
        {
            public Control FindUniqueControl(Control control, string  id) 
            {
                Control  foundControl = FindUniqueControlRecursive(control, id); 
                return  foundControl; 
           }
            protected Control FindUniqueControlRecursive(Control control, string id) 
            {
                Control foundControl = null; 
                if (control.ID == id) 
                {
                    foundControl = control;
                }
                else 
                {
                    foreach (Control childControl in control.Controls) 
                    {
                        foundControl = FindUniqueControl(childControl, id);
                        if (foundControl != null) 
                        {
                            break; 
                        }
                    }                
                }
                return foundControl; 
            }
        }
    }

    Then to use it, you just create an instance of it an use like this piece of code

    // GenlibPrv is a service class I have that creates an instance of CtrlFinderPrv class. 
      
       
    RadEditor aEd = (RadEditor) GenlibPrv.GetCtrlFinderPrv().FindUniqueControl(RadPanelBar1,"PresentadionEd"); 
     if(aEd != null )  
    {
       aEd.ImageManager.UploadPaths = imagepath;
       aEd.ImageManager.ViewPaths = imagepath;
       aEd.ImageManager.DeletePaths = imagepath;
       ...
      
      
      

    I hope this solve all your finding controls problems.

     

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Panelbar > Not able to access the controls inside itemtemplate radpanelbar