Cannot find controls inside ItemTemplate of RadPanelBar

3 posts, 0 answers
  1. Tzach Kaufmann
    Tzach Kaufmann avatar
    95 posts
    Member since:
    Aug 2008

    Posted 03 May 2012 Link to this post

    Hi

    I have a RadPanelBar, and I can't find controls inside the ItemTemplate.
    I read:Help documentation for accessing item: Accessing Items
    Help documentation for accessing control inside: Accessing Controls Inside Templates
    But it doesn't work for me.

    here is my code:

     

    <telerik:RadPanelBar ID="rpbAddFilters" runat="server">

        <Items>

            <telerik:RadPanelItem Text="RadPanelItem" runat="server">

                <Items>

                    <telerik:RadPanelItem Value="test" runat="server">

                        <ItemTemplate>

                            <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">

     

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

     

                                    `       </asp:Panel>


                            </telerik:RadCodeBlock>

                      </ItemTemplate> 
                    </telerik:RadPanelItem >
                </Items>
             </telerik:RadPanelItem >
        </Items>
    </RadPanelBar>

     

     





    function find()
    {

        var panelbar = $find("<%= rpbAddFilters.ClientID %>");

     

      

        var item = panelbar.findItemByValue("test");

        var pnlValues = item.findControl("pnlValues");

    }



    I get null value for pnlValues.


    Thanks.
  2. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 04 May 2012 Link to this post

    Ok i dont have an Example for javascript but i cant show you how you can do it on the server side. So in my case i have a "ReportViewer" inside the item so the following code finds the REportviewer inside an itemtemplate



    Dim RadPanelBar1 As RadPanelBar = CType(sender, RadPanelBar)
                    Dim InnerPanel As RadPanelItem = CType(RadPanelBar1.FindItemByValue("Impairment"), RadPanelItem)
                    Dim rptreportviewer As Microsoft.Reporting.WebForms.ReportViewer = CType(InnerPanel.FindControl("rptImpairment"), Microsoft.Reporting.WebForms.ReportViewer)


                 So look at the Value option, i use that to find the control inside the ItemTemplate 

      <telerik:RadPanelBar ID="RadPanelBar1" runat="server" ExpandMode="FullExpandedItem"
          Height="500px" Skin="Hay" Width="862px">
          <Items>
    <telerik:RadPanelItem    Text="Impairment">
                  <Items>
                      <telerik:RadPanelItem Value="Impairment">
                          <ItemTemplate>
                              <rsweb:ReportViewer Width="100%" Height="500px" ID="rptImpairment" runat="server">
                              </rsweb:ReportViewer>
                          </ItemTemplate>
                      </telerik:RadPanelItem>
                  </Items>
              </telerik:RadPanelItem>
          </Items>
      </telerik:RadPanelBar>
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 07 May 2012 Link to this post

    Hi Tzach,

    To access nested controls client-side, you need to be sure that the control in question has a client  side object. Most Telerik RadControls for ASP.NET AJAX have a client object, but the standard ASP Panel does not have a client object hence the error that you have experienced.

    All the best,
    Peter
    the Telerik team
    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 their blog feed now.
Back to Top