By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,165 Members | 1,508 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,165 IT Pros & Developers. It's quick & easy.

delete rows from datagrid

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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?

"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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

Nov 21 '05 #2

P: n/a
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
Nov 21 '05 #3

P: n/a
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 :(

Nov 21 '05 #4

P: n/a
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

Nov 21 '05 #5

P: n/a
Sam,

Try:
added line ---->dsEquivalents.AcceptChanges()
dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.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 :(

Nov 21 '05 #6

P: n/a
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.

"Pipo" <Pi**@nobody.com> wrote in message
news:eG*************@tk2msftngp13.phx.gbl...
Sam,

Try:
added line ---->dsEquivalents.AcceptChanges()
dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.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 :(


Nov 21 '05 #7

P: n/a
Sam,

Did you try that

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

dsDeleted.RejectChanges

dgDeleted.DataSource = dsDeleted

Cor
Nov 21 '05 #8

P: n/a
Sam
Pipo,
I've tried that.
Then dsDeleted' s value is 'Nothing', and doesn't contain any of the
deleted rows in dgEquivalents.

Nov 21 '05 #9

P: n/a
Sam
Cor,

Great !
That worked. Thank you so much !

Nov 21 '05 #10

P: n/a
Sam,

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

Cor
Nov 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.