datagridview saving

Discussion in 'Microsoft C# .NET' started by RobcPettit@yahoo.co.uk, Jan 18, 2008.

  1. Guest

    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
     
    , Jan 18, 2008
    #1
    1. Advertisements

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


    --
    - Nicholas Paldino [.NET/C# MVP]
    -

    <> wrote in message
    news:...
    > 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
     
    Nicholas Paldino [.NET/C# MVP], Jan 18, 2008
    #2
    1. Advertisements

  3. Guest

    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
     
    , Jan 18, 2008
    #3
  4. 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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    -


    <> wrote in message
    news:...
    > 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
     
    Nicholas Paldino [.NET/C# MVP], Jan 18, 2008
    #4
  5. Guest

    Thanks for making that clear. Working with dataset was easier than I
    thought, so Ill stick with it. Thanks for your time.
    Regards Robert
     
    , Jan 18, 2008
    #5
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ing.Zeco
    Replies:
    2
    Views:
    561
    Guest
    Oct 29, 2007
  2. SePp
    Replies:
    1
    Views:
    975
  3. Paul

    DataGridView into another DataGridView

    Paul, Mar 13, 2008, in forum: Microsoft C# .NET
    Replies:
    0
    Views:
    239
  4. Arved Sandstrom
    Replies:
    1
    Views:
    1,183
    Arved Sandstrom
    May 25, 2008
  5. Replies:
    3
    Views:
    9,169
    Marc Gravell
    Oct 1, 2008
Loading...

Share This Page