get items of RadMenuItems

2 posts, 0 answers
  1. lina fetisova
    lina fetisova avatar
    110 posts
    Member since:
    Apr 2010

    Posted 07 Sep 2010 Link to this post

    Good day!
    I have such a structure of menu:

    <telerik:RadMenu ID="RadMenu_Clients" runat="server" OnItemClick="RadMenu_Clients_ItemClick">
                                        <Items>
                                            <telerik:RadMenuItem Text="Профиль" Value="profile" ImageUrl="App_Themes/Theme1/Image/down.png">
                                                <GroupSettings ExpandDirection="Down"></GroupSettings>
                                                <Items>
                                                    <telerik:RadMenuItem Text="Настройки аккаунта" Value="settings"  />
                                                    <telerik:RadMenuItem Text="Данные предприятия" Value="data"/>
                                                    <telerik:RadMenuItem Text="Объекты" Value="objects"/>
                                                </Items>
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem Text="Заказы" Value="order" ImageUrl="App_Themes/Theme1/Image/down.png">
                                                <GroupSettings ExpandDirection="Down"></GroupSettings>
                                                <Items>
                                                    <telerik:RadMenuItem Text="Разместить заказ" Value="set_order"/>
                                                    <telerik:RadMenuItem Text="Информация о моих заказах" Value="order_info"/>
                                                </Items>
                                            </telerik:RadMenuItem>
                                        </Items>
                                    </telerik:RadMenu>


    when I click an MenuItem I want to get all of it's child items if it's a first level item and if it's a second level item I want to det it's parent and after that - all of the parent's children items and add them to enother RadMenu.

    I try to do it using Owner and Items properties.
    When I try to read First_Level_Item.Items using foreach I have an error "First_Level_Item.Items collection was changed " after first step in foreach =(
    what can I do to solve this problem?
  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 07 Sep 2010 Link to this post

    Hello Lina,

    From the error you're getting I'm assuming that the RadMenu you are looping through in the foreach statement is getting items added to itself or deleted from itself, which is not allowed when using foreach. I would suggest using a standard for loop instead.

    I hope that helps.
Back to Top