Thursday, August 9, 2007

Read XML data and bind to datagridview .NET

if you want to bind xml data to your datagrid, you need do as below:

dataSet1.ReadXml("kwyProducts.xml");
dataGridView1.DataSource =
dataSet1;
dataGridView1.DataMember = "KWYProducts";

Notes: please specify your DataMember correctly else will throw you this error:

Child list for field KWYProduscts cannot be created.

7 comments:

Anonymous said...

Thank Heaven for friendly bloggers! Short, sweet and exactly what I needed. Thanks, Buddy!

Carso Leong said...

Well, I am glad that i had help you. Happy coding.

Anonymous said...

How can you identify what the DataMember property should be?

Anonymous said...

But how to solve this problem plz help....

Atif said...

Just assigning the dataset as the datasource has resolved this problem in my case where i was assigning dataset.tables(0) as datasource

Nikola said...

Thank you man a lot! You saved my day! Finally I see my XML table :)

Pravesh Singh said...

Check this helpful link too...
Populate Grid Control From XML Document Easily

Thanks