Click here to Skip to main content
15,917,329 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i want to serialize a data enter in datagridview into a binary file. and later again deserialize that file to datagridview...
plz anyboby help me..
Posted

1 solution

Serialization of any data in a single file is quite possible, but you're trying to mix it with UI. Serialization if the data populated in the UI controls is also possible, but this is absolutely wrong idea which I won't discuss. Ever heard of separation of concerns?

You have do centralize all this around data, not UI, which can be often changed, replaced, etc. You need to have a separate data model consisting of pure data classes/structures and use the data model for both binding with UI and persistence.

For persistence, it's best to use Data Contract — most robust and non-intrusive approach.
See:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

See also my past solutions where I advocate this approach and explain its usage in more detail:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating a property files...[^].

Now, as to separation of concerns: you need to isolate UI from both universal and application-specific aspect of your product. You need to get familiar with the following architectural patterns (http://en.wikipedia.org/wiki/Architectural_pattern[^]): MVVM, MVC, MVA and MVP.

See my list of them in my past solution: how to control Controlls of a user interface form through Functions (methods)[^].

—SA
 
Share this answer
 
v3

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