datagridview saving

R

RobcPettit

Hi, I need some advice on how to proceed with saving gridview
contents. Ive got a 'datagridview control' on a form, so its window
application only not web. I fill this programatically with
'dataGridView1.Rows.Add(whatever array)' so its not bound to a
database. Once the data in I want to save the data in a format that I
can 1,reuse in the datagrid or 2, as an excel file. From what Ive
googled so far, this doesnt seem possible without using a dataset. So
am I correct in thinking that my best course of action is to--Send my
data to a database, create a dataset, bound this to datagridview and
then either stream into excel or possible save as xml file to reuse in
application. Or is there a way to avoid dataset. I dont have a problem
with 'dataset' its creating the database Im not clear on. Even after
googling. Thanks in advance.
Regards Robert
 
N

Nicholas Paldino [.NET/C# MVP]

Robert,

You don't HAVE to use a database in order to use a DataSet. You can
populate a DataSet with your data, and then just save it as XML if you want.
There is no need to interact with a database at all.
 
R

RobcPettit

Thankyou for your reply. That makes things clearer then. Create my
dataset and use in datagridview. Am I write that, to save contents of
datagridview, you have to have a dataset?.
Regards Robert
 
N

Nicholas Paldino [.NET/C# MVP]

Robert,

No, you don't have to have a dataset. You can bind a DataGridView to
anything that implements IList. The DataGridView will use the classes in
the System.ComponentModel namespace to get the information about the types
exposed through the IList implementation.

However, for the most part though, if your data needs aren't too
complex, and you don't have a specific need for this kind of typing (for the
individual rows in the data grid view), then the data set is just fine.
 
R

RobcPettit

Thanks for making that clear. Working with dataset was easier than I
thought, so Ill stick with it. Thanks for your time.
Regards Robert
 

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