Solved

How do I bind the results to a grid

Posted on 2016-11-10
3
21 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 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
Try it this way.

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

Author Closing Comment

by:David Johnson, CD, MVP
Comment Utility
works for me. Thanks
0
 
LVL 62

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now