Hi,
I'm about to develope a little application in C# where I need to save some data in an XML file. I'm viewing data from XML file in a DataGridView, but I would like to make changes and save it in the same XML file. I can't get it to save when i make changes or adding new data in the DataGridView.
Here is some code:
public Form1()
{
InitializeComponent();
dataSet1.ReadXml("C:\\tmp\\test.xml");
this.bindingSource1.DataSource = dataSet1.Tables["Row"];
dataGridView1.DataSource = bindingSource1;
}
I'm using Save button from a bindingNavigator to save:
private void saveToolStripButton_Click(object sender, EventArgs e)
{
bindingSource1 = (BindingSource)dataGridView1.DataSource;
DataTable dt = new DataTable();
dt = (DataTable)bindingSource1.DataSource;
dt.WriteXml("C:\\tmp\\test.xml");
}
I would be glad if you could help.
Thanks in advance.