Here is what I am trying to do:
1. I create RAD Menu items from data dynamically through code
2. I would like to cache the RadMenu or the RadMenuItems so that I can efficiently apply the cached version to the live version in PageLoad of my master page.
3. In 2006 version, I create a RadMenuItemCollection and placed it in the cache, then re-called it and looped through each item in the collection. That does not work in Q1 2008 version.
Here is how it makes sense to me, but for some reason, it does not work
Dim RMC as RadMenuItemCollection = Cache("RadMenuItems")
Dim RM1 as RadMenuItem = RadMenu1.Items(1)
For each item as RadMenuItem in RMC
RM1.Items.Add(item)
Next
----- SECOND ATTEMPT ---
So then I tried to simply cache the RadMenuItem (with all the Items defined) as follows
Dim DT As DataTable = CacheObj.GetData
Dim RM1 As RadMenuItem = RMMaster.Items(1)
For Each row As DataRow In DT.Rows
Dim RMItem As New Telerik.Web.UI.RadMenuItem
RMItem .Text = row("Name").ToString
RMItem .NavigateUrl = "TestPage.aspx?cl=" + row("Id").ToString
RM1.Items.Add(RMItem)
Next
Dim RMC As Telerik.Web.UI.RadMenuItem = RM1 'RMC is the Item I am going to cache and recall later
Cache.Insert("RMC", RMC, Nothing, Now.AddHours(4), TimeSpan.Zero)
'NEXT, I NEED TO RECALL THE MENU ITEM FROM THE CACHE, LOOP THROUGH THE ITEMS AND RE-ASSIGN TO THE MENU
Dim RMC As RadMenuItem = CType(Cache("RMC"), Telerik.Web.UI.RadMenuItem)
Dim RM1 As RadMenuItem = RMMaster.Items(1)
RM1.Items.Clear()
For Each item As Telerik.Web.UI.RadMenuItem In RMC.Items
RM1.Items.Add(item) ' On the second iteration I get the error here
Next
When I trace through the code I check the RMC.Items.Count() property. It starts out at 29, which is correct, then after the first time through the For Loop, it decrements to 28. As if an item is being removed from the cached RadMenuItem. I don't get this at all! The same thing happens when I try to cache and loop through a RadMenuItemCollection.