Access RadButton inside ItemTemplate

4 posts, 1 answers
  1. Steven
    Steven avatar
    9 posts
    Member since:
    Dec 2011

    Posted 06 Feb 2012 Link to this post

    I'm working with the RadToolBar, encapsulated within a RadPane, encapsulated within a RadSplitter;

    The goal is to programmatically access a RadButton, which is encapsulated within an <ItemTemplate> section of a RadToolBarButton;

    The code section is displayed below;

    Thanks in advance for any insight;

    <telerik:RadSplitter>   
      
    <telerik:RadPane ID="RadPane5" Runat="server" Width="100%" BackColor="White" BorderColor="Transparent" BorderWidth="0px" Visible="false" Scrolling="None">
      
         <telerik:RadToolBar ID="RadToolBar3" Runat="server" Height="26px" Width="100%" BackColor="Transparent" BorderColor="Transparent" Visible="false" onbuttonclick="RadToolBar3_ButtonClick">
                        <Items>  
                            <telerik:RadToolBarButton runat="server" Value="TemplateTextBox" CommandName="rcbCustomers" >    
                               <ItemTemplate>  
                                    <asp:Label Text="Customer" runat="server" ></asp:Label>
                                    <telerik:RadComboBox ID="rcbCustomer" runat="server" Text="Customers"></telerik:RadComboBox>
                                    <asp:Label ID="Group" Text="Group" runat="server" ></asp:Label>
                                    <telerik:RadComboBox ID="rcbGroup" runat="server" Text="Group"></telerik:RadComboBox>
                                    <asp:Label ID="Provider" Text="Provider" runat="server" ></asp:Label>
                                    <telerik:RadComboBox ID="rcbProvider" runat="server" Text="Provider"></telerik:RadComboBox>
                                     <asp:Label ID="Location" Text="Location" runat="server" ></asp:Label>
                                    <telerik:RadComboBox ID="rcbLocation" runat="server" Text="Location"></telerik:RadComboBox>
      
                                    <telerik:RadButton ID="rbViewReport" runat="server" Text="View Report" CommandName="View Report"></telerik:RadButton>
      
                               </ItemTemplate>  
                            </telerik:RadToolBarButton>  
                            <telerik:RadToolBarButton runat="server">   
                            </telerik:RadToolBarButton>  
                       </Items>  
                    </telerik:RadToolBar>
      
                 <rsweb:ReportViewer ID="ReportViewer7" runat="server" Width="100%" PageCountMode="Actual" Visible="false" ></rsweb:ReportViewer>
      
            </telerik:RadPane>
      
    </telerik:RadSplitter>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Feb 2012 Link to this post

    Hello Steven,

    Try the following code.
    C#:
    protected void RadToolBar3_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e)
    {
      RadToolBarItem item = RadToolBar3.FindItemByValue("TemplateTextBox");
      RadButton btn = (RadButton)item.FindControl("rbViewReport");
    }

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steven
    Steven avatar
    9 posts
    Member since:
    Dec 2011

    Posted 07 Feb 2012 Link to this post

    Update:

    RadButton rbViewReport = (RadButton)RadToolBar3.FindItemByValue("TemplateTextBox").FindControl("rbViewReport");

    Utilizing the above code snippet in the Page_Load event, a breakpoint is hit in the C# - based on a click of the RadButton;

    The next question is to how best to determine programmatically, if the Page_Load event takes place as a result of the RadButton being clicked;   


    Thanks for the reply, and I implemented the code suggestion;

    I set a breakpoint within the C# for the RadToolBar3_ButtonClick, and ran the application;

    However, if I run the application in debug mode, the breakpoint is not hit;

    Might this be related to the fact that the RadToolBar3 is nested within a RadPane, which is nested within a RadSplitter?

    Best regards
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Feb 2012 Link to this post

    Hello Steven,

    Try setting AutoPostBack as true for the RadToolBar.

    -Shinu.
Back to Top