Skip to content

Saving data from DataGridView to XML using dataset

matej kralik

Asked Sep 12, 2008, 3:12 AM EDT2 answers
Share
LinkedInX
 

Hello people, I've got a problem. Can anybody tell me how can I save data from DataGridView through Dataset to XML? I've found many useful codes that could solve problem like this:

 

Code
Dataset ds = new Dataset();
ds = (Dataset) (DataGridViewXY.Datasource);
ds.WriteXml("XML_name.xml");

 

!but actually! it doesn't work because when I run program it all stops at ds = (Dataset) (DataGridViewXY.Datasource); saying something like cannot assign Dataset to DataGridView...

 

What can I do? Isn't there problem that my DataGridView data are bound? How can I change this property/option?

 

Any hints?

 

Matej

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0

    You can't get data from a DataGridView like this. Don't you already have a DataSet or some kind of data before you display data in a DataGridView?

    What is the source of your data?

    0
  • 0
    I too got the same problem...I'm working with XML..Can anyone of u help me......
    0