Hi All !
I want to save or Export the content(Row And Column Cell) of a DatGridView To a XML file .how can i do it ? there is No DataSet Or DataTable for DataGridView .
thanks in advance for any Help !
s_mostafa_h
0
Newbie Poster
Recommended Answers
Jump to PostThere are a few threads that are about exporting to Xml using c#, take a look at those and try and apply them to suite your needs (its the same principle, put the data from the datagGrid into variables and export them in a structured tree format). if you run …
Jump to PostPerhaps consider something more like this:
string GridToXml(DataGridView source, string root, string element) { var doc = new XmlDocument(); doc.LoadXml("<" + root + " />"); foreach (var row in source.Rows) { var element = doc.CreateElement(element); foreach (var cell in row.Cells) { element.AppendChild(doc.CreateElement(cell.OwningColumn.HeaderText)); element.LastChild.InnerText = cell.FormattedValue; } doc.Firstchild.AppendChild(element); …
All 8 Replies
ChrisHunter
152
Posting Whiz in Training
Featured Poster
s_mostafa_h
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
s_mostafa_h
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
s_mostafa_h
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
s_mostafa_h
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.