checkbox list inside an itemtemplate for radmenu

6 posts, 0 answers
  1. KevinMc
    KevinMc avatar
    47 posts
    Member since:
    Dec 2006

    Posted 18 Jul 2008 Link to this post

    I am trying to add a checkbox list to an itemtemplate for the radmenu. It binds fine but when the page displays the menu item with the checkbox lists is displayed and does not expand collapse.


    <telerik:RadMenuItem runat="server" Text="Marketing">  
                <ItemTemplate> 
                    <div id="MarketingTemplate">  
                        <div> 
                            Species<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="odsSpecies" 
                                DataTextField="Name" DataValueField="Name">  
                            </asp:CheckBoxList> 
                            <asp:ObjectDataSource ID="odsSpecies" runat="server" OldValuesParameterFormatString="original_{0}" 
                                SelectMethod="GetSpeciesList" TypeName="Adisseo.Modules.DocumentManagement.KeywordManager">  
                            </asp:ObjectDataSource> 
                        </div> 
                        <div> 
                            Feed Type<asp:CheckBoxList ID="CheckBoxList2" runat="server" DataSourceID="odsFeedTypes" 
                                DataTextField="Name" DataValueField="Name">  
                            </asp:CheckBoxList> 
                            <asp:ObjectDataSource ID="odsFeedTypes" runat="server" OldValuesParameterFormatString="original_{0}" 
                                SelectMethod="GetFeedTypeList" TypeName="Adisseo.Modules.DocumentManagement.KeywordManager">  
                            </asp:ObjectDataSource> 
                        </div> 
                    </div> 
                </ItemTemplate> 
            </telerik:RadMenuItem> 
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Jul 2008 Link to this post

    Hi KevinMc,

    Thank you for contacting us.

    When you use templates as in your code, you apply the template to RadMenuItem with text "Marketing". If you want to apply a template to its child, use the following approach:

    <telerik:RadMenuItem runat="server" Text="Marketing">  
                            <Items> 
                                <telerik:RadMenuItem runat="server">  
                                    <ItemTemplate> 
                                        <div id="MarketingTemplate">  
                                            <div> 
                                                Species<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="odsSpecies" 
                                                    DataTextField="Name" DataValueField="Name">  
                                                </asp:CheckBoxList> 
                                                <asp:ObjectDataSource ID="odsSpecies" runat="server" OldValuesParameterFormatString="original_{0}" 
                                                    SelectMethod="GetSpeciesList" TypeName="Adisseo.Modules.DocumentManagement.KeywordManager">  
                                                </asp:ObjectDataSource> 
                                            </div> 
                                            <div> 
                                                Feed Type<asp:CheckBoxList ID="CheckBoxList2" runat="server" DataSourceID="odsFeedTypes" 
                                                    DataTextField="Name" DataValueField="Name">  
                                                </asp:CheckBoxList> 
                                                <asp:ObjectDataSource ID="odsFeedTypes" runat="server" OldValuesParameterFormatString="original_{0}" 
                                                    SelectMethod="GetFeedTypeList" TypeName="Adisseo.Modules.DocumentManagement.KeywordManager">  
                                                </asp:ObjectDataSource> 
                                            </div> 
                                        </div> 
                                    </ItemTemplate> 
                                </telerik:RadMenuItem> 
                            </Items> 
                        </telerik:RadMenuItem> 

    Hope this helps.

    Kind regards,
    Yana
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Muhammad Nasir
    Muhammad Nasir avatar
    4 posts
    Member since:
    Aug 2014

    Posted 11 Aug 2014 in reply to Yana Link to this post

    Sir I want to add a radcheckbox to the rad menu but keep in mind that the radmenu is getting its itmes from abc.sitemap class.
    how can i add a checkbox now?
    thanks
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2014 in reply to Muhammad Nasir Link to this post

    Hi Muhammad Nasir,

    Please take a look into this help article which discuss about add templates to RadMenu at runtime, using the ItemTemplate property. Let me know if you have any concern.

    Thanks,
    Shinu.
  6. Muhammad Nasir
    Muhammad Nasir avatar
    4 posts
    Member since:
    Aug 2014

    Posted 12 Aug 2014 in reply to Shinu Link to this post

    Unable to cast object of type 'Telerik.Web.UI.RadSearchBox' to type 'System.Web.UI.ITemplate'.

    And here is my code

    RadMenu1.ItemTemplate = New RadSearchBox()
    I want to add a radsearchbox to the radmenu
    thanks
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Aug 2014 in reply to Muhammad Nasir Link to this post

    Hi Muhammad Nasir,

    Please try the below C# code snippet which works fine at my end.

    C#:
    protected override void OnInit(EventArgs e)
    {
        RadMenu1.ItemTemplate = new SearchBoxTemplate();
        base.OnInit(e);
    }
    class SearchBoxTemplate : ITemplate
    {
        public void InstantiateIn(Control container)
        {
            RadSearchBox searchBox = new RadSearchBox();
            searchBox.ID = "rsearchItems";
            container.Controls.Add(searchBox);
            Label label1 = new Label();
            label1.ID = "lblItems";
            label1.Text = "Text";
            label1.DataBinding += new EventHandler(label1_DataBinding);
            container.Controls.Add(label1);
        }
        private void label1_DataBinding(object sender, EventArgs e)
        {
            Label target = (Label)sender;
            RadMenuItem item = (RadMenuItem)target.BindingContainer;
            string itemText = (string)DataBinder.Eval(item, "Text");
            target.Text = itemText;
        }
    }

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017