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

Access RadButton inside ItemTemplate

3 Answers 155 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 06 Feb 2012, 10:22 PM
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>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Feb 2012, 06:01 AM
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.
0
Steven
Top achievements
Rank 1
answered on 07 Feb 2012, 03:10 PM
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
0
Accepted
Shinu
Top achievements
Rank 2
answered on 09 Feb 2012, 07:28 AM
Hello Steven,

Try setting AutoPostBack as true for the RadToolBar.

-Shinu.
Tags
ToolBar
Asked by
Steven
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Steven
Top achievements
Rank 1
Share this question
or