in Education by
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" ?> Title 1a Description 1a Link URL 1a Image URL 1a Image ToolTip 1a Title 2a Description 2a Link URL 2a Image URL 2a Image ToolTip 2a Title 3a Description 3a Link URL 3a Image URL 3a Image ToolTip 3a Title 1b Description 1b Link URL 1b Image URL 1b Image ToolTip 1b Title 2b Description 2b Link URL 2b Image URL 2b Image ToolTip 2b Title 3b Description 3b Link URL 3b Image URL 3b Image ToolTip 3b 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)

1 Answer

0 votes
by
Instead of using aggregation you could try the following: var groups = from x in xd.Element("Menu").Elements("MenuItem") select new { Items = (from c in x.Elements("MenuContent") select new { Description = c.Element("Description").Value, ImageToolTip = c.Element("ImageToolTip").Value, ImageUrl = c.Element("ImageUrl").Value, LinkUrl = c.Element("LinkUrl").Value, Title = c.Element("Title").Value }).ToList() }; and then change the Repeater2 tag to: ' runat="server">

Related questions

0 votes
    I need to pull item quantity from a DB2 database from an aspx page and then update after the quantity ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I have a question to understand the concept of ASP.NET with each client browser. I am trying to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    Good day, I am going to try be as breif but informative as possible, I am using asp.net 3.5 and ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    So the problem is i don't get get a value from textbox field on GridView RowUpdating event. Here ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I want to make a button Go To Cart visible after adding a product into cart. But when page gets ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I have been developing a webpage which uses n number of dropdownlists which are binding dynamically inside a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I have a fileupload option in my project. It inclueds a query which returns a dataset. It works fine ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I have a master page with a form element and the defaultbutton attribute set to a server-side ImageButton. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    I have a Login control placed inside LoginView control contained within a PANEL. I want to set login button ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    I am developing solution where there are three webapi projcets. Each of them is secured with JWT tokens ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    All How can I download a file so the user sees that it is downloading (like with a stream?) I ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I'm working on a DNN skin using Christoc's DNN templates and when I create a normal ASP.NET ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I have two submit buttons and a few textboxes on my page. When I enter details in the textbox and hit ... model.FirsttName) @Html.TextBoxFor(model => model.LastName) Get History...
asked May 22, 2022 in Education by JackTerrance
0 votes
    Description: I have a solution in Visual Studio which has multiple projects as application layers. Business Logic ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I have two submit buttons and a few textboxes on my page. When I enter details in the textbox and hit ... model.FirsttName) @Html.TextBoxFor(model => model.LastName) Get History...
asked May 17, 2022 in Education by JackTerrance
...