Click here to Skip to main content
15,029,369 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good day,

I have a form, where the user can enter various data.
These data shoul be saved into 1 xml file.

I've seen many examples of 1 datagridview exporting to XML, but not multiple (DG1, DG2,DG3).

Same data must be imported afterwards as well.

Many thanks for your professional help


addition by the OP in an "answer"
To add, the form contains multiple tabs and each tab contains 1 datagridview.

Thanks for all your help
Updated 21-Oct-12 11:03am

Here is the point where you need to get a reminded that you are a software developer. Even if you used some code sample, you should have understood how it works instead of using it as a cookbook recipe. You need to be able to write code, not take fragments of code here and there trying to put them together using trial-and-error "method". And you need to get a habit to write code from scratch to the requirements, using library code (and creating such libraries, growing your algorithmic repertoire), not pieces of application. Software reuse means developing and using libraries, not copy-and-paste.

Let me tell you that there is no principal difference between one or more grid views. If you see a problem in "converting" single grid view code into multiple, you just don't even try to do any professional chores. Besides, you should understand that there is no such thing as "just XML" which you can write. There are different data models which can be created to different application, and their structures can be expressed as some meta-data, which corresponds to one or another XML schema. The same application data representation can be modeled in a number of different ways giving different schemes.

Besides, it's possible that the code samples you saw were not good. You should not have code saving some UI state in XML file, not when UI expresses some data set. Instead, you need to isolate UI from data model, and data model from persistence. In the simplest case, you can have an instance of a data model in memory and have procedures for populating UI from data, and modifying data from UI state. And the data, not UI, should be uses for persistence. Everything is already done for you, as you can use Data Contract which will allow you to avoid dealing with XML directly. Please see:[^].

Please also see my past answers where I advocate this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

Sorry, but if I would like an of-the-shelf example I would shop for a software program. Instead, i'm trying to learn it and actually already for quit a lot, but this ones keeps me puzzling.

Sorry for waisting your time, but then again, DO NOT RESPOND!!
Sandeep Mewara 22-Oct-12 15:53pm
This is not an answer. Please use 'Have a Question or Comment' link to respond to an answer. It will notify answerer of your comment such that he can come back and reply. Or if needed, use Improve Question link to edit/update your question at anytime.

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