Click here to Skip to main content
15,896,359 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have one datagridview that bind with database data. i want to export or convert that data to a xml file in C#.How can i do this?


Please Suggest Me.....
Posted
Comments
[no name] 4-Sep-14 7:38am    
http://www.google.com/search?q=writexml

1 solution

You can use Datatable

C#
DataTable dst = new DataTable();
dst.Columns.Add("no", typeof(int));
dst.Columns.Add("name", typeof(string));
DataRow row = dst.NewRow();
row[0] = 1;
row[1] = "ROW1";

DataRow row1 = dst.NewRow();
row1[0] = 2;
row1[1] = "ROW2";
dst.Rows.Add(row);
dst.Rows.Add(row1);
dst.TableName = "DataGridviewXml";
dst.WriteXml(@"PATH\YOURXML.xml", true);
 
Share this answer
 

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