FindControl

3 posts, 0 answers
  1. brad
    brad avatar
    14 posts
    Member since:
    Aug 2008

    Posted 22 Jan 2009 Link to this post

     <telerik:RadToolBar ID="_toolbar" runat="server" AutoPostBack="true" OnButtonClick="RadToolBar1_ButtonClick">
                <Items>
                    <telerik:RadToolBarButton Text="Save" CommandName="Save" ToolTip="Save"></telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Save As" CommandName="SaveAs" ToolTip="Save As"></telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Show/Hide Conditions" CommandName="Conditions" ToolTip="Show/Hide Conditions"></telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Search" CommandName="Search" ToolTip="Search"></telerik:RadToolBarButton>
                    <telerik:RadToolBarButton IsSeparator="true"></telerik:RadToolBarButton>
                    <telerik:RadToolBarButton>
                        <ItemTemplate>
                            <telerik:RadComboBox ID="comboBox" runat="server" AutoPostBack="true" CausesValidation="false" AllowCustomText="false"
                                ShowDropDownOnTextboxClick="true" EmptyMessage="Teams" RadComboBoxImagePosition="Left">
                            </telerik:RadComboBox>
                        </ItemTemplate>
                    </telerik:RadToolBarButton>
                </Items>
            </telerik:RadToolBar>

    so theres my toolbar

    im using:

    RadComboBox combo = (RadComboBox)_toolbar.FindControl("comboBox");

    to find the RadComboBox.

    no luck. returns null everytime. suggestions?





  2. brad
    brad avatar
    14 posts
    Member since:
    Aug 2008

    Posted 22 Jan 2009 Link to this post

    completed using

    RadComboBox combo = (RadComboBox)_toolbar.Controls[5].Controls[1];

    im really not sure why the FindControl could not locate it. perhaps it does not access controls through the <ItemTemplate> ?





  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Jan 2009 Link to this post

    Hello Brad,

    You can access the RadComboBox in the ItemTemplate of RadToolBarButton using FindControl method as shown below:
    cs:
    foreach (RadToolBarButton btn in RadToolBar1.Items) 
            { 
                RadComboBox combo = (RadComboBox)btn.FindControl("comboBox"); 
                 
            } 

    Thanks
    Princy.
Back to Top