Home All Groups Group Topic Archive Search About

delete rows from datagrid

Author
4 Apr 2005 8:07 AM
Sam
Hi,
I'm doing the following :

Dim dsDeleted As New DataSet
dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
dgDeleted.DataSource = dsDeleted

basically I create a dataset dsDeleted that gets all the rows deleted
in dsEquivalents, and I fill a datagrid dgDeleted with this dataset.
My problem is that whatever rows I delete, dgDeleted is always empty
and does not seem to get the deleted rows.

What should I do to store the deleted rows in a dataset so i can
proceed to further operations ?

Thx

Author
4 Apr 2005 9:09 AM
Pipo
Hi Sam,

From the MSDN:
Gets a copy of the DataSet containing all changes made to it since it was
last loaded, or since AcceptChanges was called

Did you call Acceptchanges?



Show quoteHide quote
"Sam" <samuel.berthe***@voila.fr> wrote in message
news:1112602074.536710.245640@o13g2000cwo.googlegroups.com...
> Hi,
> I'm doing the following :
>
> Dim dsDeleted As New DataSet
> dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
> dgDeleted.DataSource = dsDeleted
>
> basically I create a dataset dsDeleted that gets all the rows deleted
> in dsEquivalents, and I fill a datagrid dgDeleted with this dataset.
> My problem is that whatever rows I delete, dgDeleted is always empty
> and does not seem to get the deleted rows.
>
> What should I do to store the deleted rows in a dataset so i can
> proceed to further operations ?
>
> Thx
>
Author
4 Apr 2005 9:28 AM
Sam
thx
I've changed my code to this :

Dim dsDeleted As New DataSet
dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
added line ---->dsEquivalents.AcceptChanges()
dgDeleted.DataSource = dsDeleted

but dgDeleted is still empty. I don't know why :(
Author
4 Apr 2005 9:29 AM
Pipo
Sam,

Try:
added line ---->dsEquivalents.AcceptChanges()
dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)


Show quoteHide quote
"Sam" <samuel.berthe***@voila.fr> wrote in message
news:1112606928.407032.195010@l41g2000cwc.googlegroups.com...
> thx
> I've changed my code to this :
>
> Dim dsDeleted As New DataSet
> dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
> added line ---->dsEquivalents.AcceptChanges()
> dgDeleted.DataSource = dsDeleted
>
> but dgDeleted is still empty. I don't know why :(
>
Author
4 Apr 2005 9:35 AM
Pipo
Sam,

Sorry I meant:

added line ---->dsEquivalents.AcceptChanges()
'Code wich deletes the records
dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)

Also try this to see if there are changes:
If Not myDataSet.HasChanges(DataRowState.Deleted) Then Exit Sub

And if you are filling the dataset with records yourself (not database)
try also the AcceptChangesDuringFill = false property.

Show quoteHide quote
"Pipo" <P***@nobody.com> wrote in message
news:eGbejkPOFHA.904@tk2msftngp13.phx.gbl...
> Sam,
>
> Try:
> added line ---->dsEquivalents.AcceptChanges()
> dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
>
>
> "Sam" <samuel.berthe***@voila.fr> wrote in message
> news:1112606928.407032.195010@l41g2000cwc.googlegroups.com...
> > thx
> > I've changed my code to this :
> >
> > Dim dsDeleted As New DataSet
> > dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
> > added line ---->dsEquivalents.AcceptChanges()
> > dgDeleted.DataSource = dsDeleted
> >
> > but dgDeleted is still empty. I don't know why :(
> >
>
>
Author
4 Apr 2005 9:41 AM
Sam
Pipo,
I've tried that.
Then dsDeleted' s value is 'Nothing', and doesn't contain any of the
deleted rows in dgEquivalents.
Author
4 Apr 2005 9:23 AM
Cor Ligthert
Sam,

A datagrid does not show deleted row, and that change is not changed.

Maybe you can use the RejectChanges method on that  extra dataset, that you
made with getchanges. (Know that new added rows which are deleted are not
seen as deleted however directly will removed with a delete).

I hope this helps,

Cor
Author
4 Apr 2005 9:32 AM
Sam
Cor,
This new added datagrid was just to see if my rows were properly marked
as deleted anyway. I do not intend to keep this datagrid.
But apparentely my deleted rows are NOT marked as deleted as I would
assume they would be added to this datagrid otherwise. Basically I want
my dsDeleted dataset to contain rows that are marked as deleted so that
I can call a stored procedure according to what is in this dataset.
Any idea what might go wrong ?

thx
Author
4 Apr 2005 9:39 AM
Cor Ligthert
Sam,

Did you try that

Dim dsDeleted As New DataSet
dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)

dsDeleted.RejectChanges

dgDeleted.DataSource = dsDeleted

Cor
Author
4 Apr 2005 9:50 AM
Cor Ligthert
Sam,

I tested it, this does what you want to do.

Cor
Author
4 Apr 2005 9:51 AM
Sam
Cor,

Great !
That worked. Thank you so much !