Forum guidelines
AuthorQuestion
Datagrid dump to a dataset
Posted on: 14 Nov 2008

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


AuthorReply
Re: Datagrid dump to a dataset
Posted on: 15 Nov 2008  

Is it a web or windows grid view


Every one among us was a beginner once.
http://dotnetuniver.blogspot.com/
Re: Datagrid dump to a dataset
Posted on: 15 Nov 2008  
Windows
Re: Datagrid dump to a dataset
Posted on: 15 Nov 2008  

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?

Every one among us was a beginner once.
http://dotnetuniver.blogspot.com/
Re: Datagrid dump to a dataset
Posted on: 15 Nov 2008  

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


Re: Datagrid dump to a dataset
Posted on: 16 Nov 2008  

Ok, then you want that the datagridview is not bound, am I wrong?

you do use an unbound datagrid to fill a data table

Every one among us was a beginner once.
http://dotnetuniver.blogspot.com/
Re: Datagrid dump to a dataset
Posted on: 16 Nov 2008  

Hi,

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

Thanks


Re: Datagrid dump to a dataset
Posted on: 16 Nov 2008  

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



Every one among us was a beginner once.
http://dotnetuniver.blogspot.com/

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.