I'm trying to create a menu for my web site programmatically from an xml file. The menu has three links in the menu bar that expand on a mouse over event and reveal content (links and images). The xml file has MenuItem nodes which correspond to the three links in the menu bar and MenuContent nodes which correspond to the mouse over content. In psuedo-code, here's what I'd like to do:
Read the xml file.
Group the xml file by MenuItem nodes.
Populate the outer repeater with MenuItem data.
For each MenuItem node, populate the inner repeater with MenuContent data.
My problem is that I don't know how to properly group the MenuItem nodes and then populate the inner repeater. The C# code for grouping was something that worked in an older project, but doesn't work in this case. I included it just to get some code out there.
How can I fix the C# code to group by the MenuItem nodes and populate the inner repeater?
var menuPath = Server.MapPath("~/Menu.xml");
var xDocument = XDocument.Load(menuPath);
var menuItems = new List();
var groups = (from x in xDocument.XPathSelectElements("Menu")
group x by new
{
Description = x.Descendants("Description").FirstOrDefault().Value,
ImageToolTip = x.Descendants("ImageToolTip").FirstOrDefault().Value,
ImageUrl = x.Descendants("ImageUrl").FirstOrDefault().Value,
LinkUrl = x.Descendants("LinkUrl").FirstOrDefault().Value,
Title = x.Descendants("Title").FirstOrDefault().Value
} into g
select g).ToDictionary(g => g.Key, g => g.ToArray());
Repeater1.DataSource = groups;
Repeater1.DataBind();
<?xml version="1.0" encoding="utf-8" ?>
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)