Solved

How do I bind the results to a grid

Posted on 2016-11-10
3
37 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 63

Accepted Solution

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

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

Author Closing Comment

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

Expert Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 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