Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I bind the results to a grid

Posted on 2016-11-10
3
Medium Priority
?
75 Views
Last Modified: 2016-11-10
  private void button1_Click(object sender, EventArgs e)
        {
            var xdoc = XDocument.Load(@"..\..\Employees.xml");

            var results = from emp in xdoc.Root.Elements()
                          from child in emp.Elements()
                          select new
                          {
                              TagName = child.Name.LocalName,
                              Value = child.Value
                          };
            dataGridView1.DataSource = results;  // this obviously doesn't work
        }
    }
}

Open in new window


As shown in the answer @ https://www.experts-exchange.com/questions/28982335/c-code.html#a41882648

We all have to start learning somewhere
What I wantEmployees.xml
0
Comment
  • 2
3 Comments
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 41883005
Try it this way.

dataGridView1.DataSource = results.ToList();
0
 
LVL 84

Author Closing Comment

by:David Johnson, CD, MVP
ID: 41883035
works for me. Thanks
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 41883086
Not a problem David, glad I was able to help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question