473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7214
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.WriteXm l

"Anthoni" <de*********@gm ail.comwrote in message
news:11******** **************@ w5g2000hsg.goog legroups.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<YourClasso r BindingList<You rClass>
as the data, then you should be able to simple use the XmlSerializer /
DataContractSer ializer 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_nameSOM E NAME </item_name>
<item_descripti onDESCRIPTION</item_descriptio n>
</item>
<item>
<item_nameSOM E OTHER_NAME </item_name>
<item_descripti onOTHER_DESCRIP TION</item_descriptio n>
</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.Creat e("blahfile.xml "))
{
writer.WriteSta rtElement("item s");
foreach(blah in blahs) {
writer.WriteSta rtElement("item ");
// perhaps a foreach on columns here...
writer.WriteEle mentString("ite m_name", blahName);
writer.WriteEle mentString("ite m_description",
blahDescription );
writer.WriteEnd Element(); // end of "item"
}
writer.WriteEnd Element(); // 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
10231
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 me to a document that shows how this can be done? Thank you
2
7204
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 control, but I haven't found a way to save the data on program exit. There must be a way, after all, you can't expect people to re-input all the data every time they use your program! Any help is appreciated.
2
8343
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 - cause i want to add this row to a specific location. and it does not match to sort order. Regards. and thanks. base.Rows.InsertCopy(base.CurrentRow.Index, 1); base.Rows.Insert(base.CurrentRow.Index, 1);
0
1333
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 is programatically added the gridrow for manual entries disappears and disallows such entries. How can this problem be solved, i.e maintaining the manual entry row although rows are programatically added ?
7
3625
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 DataSet.AcceptChanges() - DataGridView bound columns -Click on header for sorting Is there a event, that I can use to detect this situation and then
1
2320
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 this and I have not been able to find relevant articles on this. Thanks for any help !
1
2063
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
7437
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 exceeds the DataGridView's height, it becomes impossible to view the out of sight portion of the row. Down arrow of the text cursor simply moves the caret down out of sight. Contrary to expectations, the DataGridView's scroll bar doesn't smoothly...
0
1336
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 populate after searching for today's date and then increment a week at a time by repopulating after a PageDown event and changing the start index. No problem with PgUp and PgDn but I find I find myself in the middle of a nightmare controlling...
0
8339
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8535
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8629
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2757
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.