Save Row in DataGridView

  • Thread starter Thread starter Christian
  • Start date Start date
C

Christian

Hi, how i can save the rows in a DataGridView in c# 2008?
i haven't a DB but only datagridview...
 
Christian said:
Hi, how i can save the rows in a DataGridView in c# 2008?
i haven't a DB but only datagridview...

I think the only thing you can do it iterate over the Rows collection of
the DataGridView and do something with each row in turn, where
"something" really depends on what you're trying to achieve.

You could push the data in to DataTable - which to be honest is a better
place to keep it in the first place; you can back your DataGridView with
a DataTable directly, by binding it via the DataSource property.

DataTable implements the ISerializable and IXmlSerializable interfaces,
so you can use their respective methods (GetObjectData() and WriteXml())
to store the data to disk.
 
Well, what is the data?
the data is a collection of my DVD; title, Director, Genre, ecc...

And in what format do you want to save it?
the format is text; i create an interface to insert a DVD
information....
it's difficult to create this program?
 
As Chris notes, using a DataTable is a simple option, as a DataTabe is
easy to bind to a DataGridView, and easy to load/save (especially as
xml). There are plenty of other approaches, but this should work very
quickly and easily.

Marc
 
Back
Top