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

get items of RadMenuItems

1 Answer 134 Views
Menu
This is a migrated thread and some comments may be shown as answers.
lina fetisova
Top achievements
Rank 1
lina fetisova asked on 07 Sep 2010, 12:27 PM
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?

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 07 Sep 2010, 06:48 PM
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.
Tags
Menu
Asked by
lina fetisova
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or