Skip to content

Datagrid dump to a dataset

George Laing

Asked Nov 14, 2008, 12:37 PM EST7 answers
Share
LinkedInX

Hi,

  I ned to dump data from a grid to a dataset to update a new DB, I have created the dataset, The problem I am having is getting the data from the grid  Can anyone explain how I can dump the grid into my dataset?

Thanks,

George

6 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    +1
    Is it a web or windows grid view
    +1
  • Bechir Bejaoui
    +1
    if you put

    datagridVew.datasource = yourdataset;
    datagridview.datamember = dataset.tables[0].TableName;

    Normally, the datagridview and your data set  are tied, am I miss understand you?
    +1
  • +1

    Hi,

      In this case the datagrid was filled by a xml file, I want to put the changes from the grid to a new dataset. I can't seem to get the grid to load a new dataset.

    Thanks

    +1
  • Bechir Bejaoui
    +1
    Ok, then you want that the datagridview is not bound, am I wrong?

    you do use an unbound datagrid to fill a data table
    +1
  • +1

    Hi,

      The datagrid does have a datsoource but the member field is empty.

    Thanks

    +1
  • Bechir Bejaoui
    +1
    Because if you want that you datagrid be unbound and that from it you transimt data to the data set then you have to create a data table in the data set to recieve data

    datatable dt = ds.tables.add(...)

    then you have to dimension the data grid

    for(int i =0;i<dt.columns.count;i++)
    {
        datagridview1.columns.add("column" + i.tostring(),"column" + i.tostring());
    }

    for(int i =0;i<dt.Rows.count;i++)
    {
        datagridview1.Rows.add();
    }

    once the datagridview is dimensioned

    then you create double boucle that assign each value entred in the datagridview to the data table

    dt[index][index]<-- datagridview[index,index].value
    +1
  • 1 short reply
    • +1
      Windows
      +1