473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

write data of unbound datagridview to XML

Dear All,
I need to export data of unbound datagridview to XML file.
Since my DataSource is NULL, What other options do I have?
Does i need to make 2 loops (on all the records and inside loop of all
the cells)
read data and export it to XML?
TIA,

May 30 '07 #1
4 7183
Hi,

I see no other option.

You could define a Dataset/DataTable with the correct definition and then
just iterate in the Datagridview rows.

At the end you just use DataSet.WriteXml

"Anthoni" <de*********@gmail.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
Dear All,
I need to export data of unbound datagridview to XML file.
Since my DataSource is NULL, What other options do I have?
Does i need to make 2 loops (on all the records and inside loop of all
the cells)
read data and export it to XML?
TIA,

May 30 '07 #2
Any reason it must be unbound? If you could declare a simple class to
hold the values, and have a List<YourClassor BindingList<YourClass>
as the data, then you should be able to simple use the XmlSerializer /
DataContractSerializer to get fairly standard xml.

Marc

May 30 '07 #3
Thanks,
It seems that I need to do all the work, the problem is that my
knowlagde in XML is very poor.
therefore, in order to get somthing like
<?xml version="1.0" encoding="iso-8859-1" ?>
<items>
<item>
<item_nameSOME NAME </item_name>
<item_descriptionDESCRIPTION</item_description>
</item>
<item>
<item_nameSOME OTHER_NAME </item_name>
<item_descriptionOTHER_DESCRIPTION</item_description>
</item>
</items>
Any simple sample to do it?
TIA,

May 31 '07 #4
As a very simple (and equally: untested) example (using XmlWriter):

using (XmlWriter writer = XmlWriter.Create("blahfile.xml"))
{
writer.WriteStartElement("items");
foreach(blah in blahs) {
writer.WriteStartElement("item");
// perhaps a foreach on columns here...
writer.WriteElementString("item_name", blahName);
writer.WriteElementString("item_description",
blahDescription);
writer.WriteEndElement(); // end of "item"
}
writer.WriteEndElement(); // end of "items"
writer.Close();
}

XmlWriter can write to files, streams, text-writers and
string-builders etc - it isn't limited to files. Obviously you need to
change every "blah" to something more useful. If you choose to loop on
the columns, you might be able to use part of the column headers for
the names?

Marc
May 31 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dm1608 | last post by:
Hello, I have a DataGridView control in VB.NET 2005 that I would like to iterate thru row by row and parse out the individual columns into variables. Can someone provide me example code or direct...
2
by: JeffGoneMad | last post by:
Hi, I'm kind of a newbie to VB, so I hope this doesn't seem too trivial. I have a problem with the DataGridView control. I can find all kinds of stuff about populating data in a DataGridView...
2
by: inpuarg | last post by:
Is it possible that - or is there any workarround for adding a new unbound row to a datagridview at bound mode ? Theese are not working. And i don 't want to add a row to dataset then rebind -...
0
by: MethMath | last post by:
I have an unbound DataGridView which I programatically feed new rows. As I want to maintain possibility for user to add additional rows manually I maintain AllowUserToAddRows=True, but when a row...
7
by: Rainer Queck | last post by:
Hi NG, Why is it, that in my DataGridView all columns which are not bound to a "DataProperty" loos thier content in a couple of occasions? This happens if: - Underlaying...
1
by: Silvester | last post by:
I need to drag drop & copy entire row contents from a Source databound datagridview to a Target unbound datagridview. Source is set to SelectionMode fullrowselect. I am not sure how to achieve...
1
by: kevinlkingma | last post by:
Hi All: Can someone tell me how to programatically move to a specific row in an unbound datagridview control (and move the cursor on to that row)? Kevin
3
by: Richard Lewis Haggard | last post by:
I have an unbound DataGridView control that has some cells that may contain more multi-line text than can be completely displayed in the available screen space. When the height of its row to...
0
by: Ed Bitzer | last post by:
Appreciate some direction on populating an unbound DataGridView with an one dimensional array of date an appointments (a calendar) read from a coma delimited text file. My original approach was to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.