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

checkbox list inside an itemtemplate for radmenu

5 Answers 137 Views
Menu
This is a migrated thread and some comments may be shown as answers.
KevinMc
Top achievements
Rank 1
KevinMc asked on 18 Jul 2008, 08:30 PM
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> 

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 21 Jul 2008, 01:58 PM
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
0
Muhammad Nasir
Top achievements
Rank 1
answered on 11 Aug 2014, 07:57 AM
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
0
Shinu
Top achievements
Rank 1
answered on 11 Aug 2014, 08:29 AM
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.
0
Muhammad Nasir
Top achievements
Rank 1
answered on 12 Aug 2014, 10:12 AM
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
0
Shinu
Top achievements
Rank 1
answered on 12 Aug 2014, 11:55 AM
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.
Tags
Menu
Asked by
KevinMc
Top achievements
Rank 1
Answers by
Yana
Telerik team
Muhammad Nasir
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Share this question
or