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

ItemCreated not firing

1 Answer 95 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
DMC Helpdesk
Top achievements
Rank 1
DMC Helpdesk asked on 22 Jun 2010, 06:18 PM
My ASPX code:
<telerik:RadToolBar ID="mainToolBar" runat="server"  
                        Style="z-index: 90001" Width="100%" 
                        OnButtonClick="mainToolBar_ButtonClick"  
                        OnClientButtonClicked="OnClientButtonClicked"  
                        onitemcreated="mainToolBar_ItemCreated"
                        <Items> 
                            <telerik:RadToolBarButton ImageUrl="~/images/toolbar/New.gif" AccessKey="N" Text="<u>N</u>ew" 
                                ToolTip="New" Value="New"
                            </telerik:RadToolBarButton> 
                            <telerik:RadToolBarButton IsSeparator="true" /> 
                            <telerik:RadToolBarButton ImageUrl="~/images/toolbar/print.gif" ToolTip="Print" CommandName="Print" 
                                Value="Print" /> 
                            <telerik:RadToolBarButton ImageUrl="~/images/toolbar/Excel.png" AccessKey="N" ToolTip="Excel" 
                                Value="ExportToExcel" PostBack="false"
                            </telerik:RadToolBarButton> 
                            <telerik:RadToolBarButton IsSeparator="true" /> 
                            <telerik:RadToolBarButton ImageUrl="~/images/toolbar/Refresh.gif" ToolTip="Refresh" 
                                Value="Refresh" PostBack="false"/> 
                            <telerik:RadToolBarButton IsSeparator="true" /> 
                            <telerik:RadToolBarButton ImageUrl="~/images/toolbar/delete.gif" ToolTip="Delete" 
                                Value="Delete" PostBack="false" /> 
                                <telerik:RadToolBarButton Value="Search" > 
                                <ItemTemplate> 
                                 
                                </ItemTemplate> 
                                </telerik:RadToolBarButton> 
                        </Items> 
                    </telerik:RadToolBar> 


my CS code:
 protected void mainToolBar_ItemCreated(object sender, Telerik.Web.UI.RadToolBarEventArgs e) 
    { 
        throw new Exception("ItemCreated fired");  
        
    } 



Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Jun 2010, 10:27 AM
Hello,

The ItemCreated event occurs for each new item that is added to the Items collection of the toolbar. In other words, the event fires when adding a dynamically created RadToolBarItem to RadToolBar, or when binding the toolbar to a data source.

If you wand to access the items in RadToolBar, then you can iterate through the items as shown below.
C#:
 
        foreach( RadToolBarItem item in mainToolBar.Items ) 
        { 
             // Your code to modify items 
        } 







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