I have a RADMenu control that has the following markup in the aspx page:
What I need to do is append items to the Services menu item based on database fields. I am using LINQ and a HashTable (plus HttpCache) to pull this off with the following code:
Everything builds great and runs, but the menu only appends the last item in the dictionary object. I've gone through the debugger and confirmed if the cache is null that it gets populated with all items (supposed to be 2) and the final loop tells the menu to append two items but only the last one added shows up. I confirmed this by adding a third Service to the database and now it is the only one that shows up.
I'm sure I am doing something really simple wrong here, but could someone point me in the right direction?
PS - The forums site has trouble in FF3 so I am forced to use IE. Any chance this will be resolved soon?
<telerik:RadMenu ID="RadMenu1" Runat="server" Flow="Horizontal"> | |
<CollapseAnimation Type="OutQuint" Duration="200" /> | |
<Items> | |
<telerik:RadMenuItem Text="Site Menu"> | |
<Items> | |
<telerik:RadMenuItem Text="Entry Page" NavigateUrl="~/admin/entry.aspx" /> | |
<telerik:RadMenuItem Text="FAQ"> | |
<Items> | |
<telerik:RadMenuItem Text="Categories" NavigateUrl="~/admin/faq-categories.aspx" /> | |
<telerik:RadMenuItem Text="Items" NavigateUrl="~/admin/faq.aspx" /> | |
</Items> | |
</telerik:RadMenuItem> | |
<telerik:RadMenuItem Text="Helpful Tips" NavigateUrl="~/admin/helpfultip.aspx" /> | |
<telerik:RadMenuItem Text="Links"> | |
<Items> | |
<telerik:RadMenuItem Text="Categories" NavigateUrl="~/admin/link-categories.aspx" /> | |
<telerik:RadMenuItem Text="Items" NavigateUrl="~/admin/link.aspx" /> | |
</Items> | |
</telerik:RadMenuItem> | |
<telerik:RadMenuItem Text="News" NavigateUrl="~/admin/news.aspx" /> | |
<telerik:RadMenuItem Text="Services" /> | |
</Items> | |
</telerik:RadMenuItem> | |
</Items> | |
</telerik:RadMenu> |
What I need to do is append items to the Services menu item based on database fields. I am using LINQ and a HashTable (plus HttpCache) to pull this off with the following code:
Hashtable items = (HttpContext.Current.Cache["Services"] != null) ? (Hashtable)HttpContext.Current.Cache["Services"] : new Hashtable(); | |
if (items.Count == 0) | |
{ | |
using (LemonLawyerDataContext data = new LemonLawyerDataContext()) | |
{ | |
var services = from s in data.Services orderby s.Name select s; | |
foreach (Service s in services) | |
{ | |
items.Add(s.Id, s.Name); | |
} | |
} | |
HttpContext.Current.Cache["Services"] = items; | |
} | |
foreach (Telerik.Web.UI.RadMenuItem item in this.RadMenu1.Items[0].Items) | |
{ | |
if (item.Text == "Services") | |
{ | |
foreach (DictionaryEntry en in items) | |
{ | |
item.Items.Insert(item.Items.Count, new Telerik.Web.UI.RadMenuItem(en.Value.ToString(), "~/admin/services.aspx?serviceid=" + en.Key.ToString())); | |
//item.Items.Add(new Telerik.Web.UI.RadMenuItem(en.Value.ToString(), "~/admin/services.aspx?serviceid=" + en.Key.ToString())); | |
} | |
} | |
} | |
Everything builds great and runs, but the menu only appends the last item in the dictionary object. I've gone through the debugger and confirmed if the cache is null that it gets populated with all items (supposed to be 2) and the final loop tells the menu to append two items but only the last one added shows up. I confirmed this by adding a third Service to the database and now it is the only one that shows up.
I'm sure I am doing something really simple wrong here, but could someone point me in the right direction?
PS - The forums site has trouble in FF3 so I am forced to use IE. Any chance this will be resolved soon?