Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project,
There are lots of datagridview and a binded dataset(datatables) to save and load the data.
I can save dataset to xmlfile in easyway (dataset.writexml())

but i also want to save lots of textbox or richbox control data to same xml file or any other file format.
Can you provide advice for me?

What I have tried:

VB
ds.WriteXml(pathDSdata, XmlWriteMode.WriteSchema)
Posted
Updated 16-Feb-17 20:49pm

1 solution

try any one

Method 1 :

DataSet ds = new DataSet();
           DataTable dtControls = new DataTable();
           dtControls.Columns.Add("txtBox1Value");
           dtControls.Columns.Add("txtBox2Value");
           dtControls.Columns.Add("richTextBox1Value");
           dtControls.Columns.Add("richTextBox2Value");
           DataRow row = dtControls.NewRow();
           row["txtBox1Value"] = txtBox1Value.Text;
           row["txtBox2Value"] = txtBox2Value.Text;
           row["richTextBox1Value"] = richTextBox1Value.Text;
           row["richTextBox2Value"] = richTextBox2Value.Text;
           dtControls.Rows.Add(row);
           ds.Tables.Add(dtControls);
           ds.WriteXml("< Path to the xml file>");


note: you shall add this table to the existing dataset to append the data, or you can create a new file.

Method 2
write class properties to XML File [^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900