Save Row in DataGridView

C

Christian

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

Chris Crowther MBCS

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.
 
C

Christian

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?
 
M

Marc Gravell

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top