PC Review


Reply
Thread Tools Rate Thread

delete rows from datagrid

 
 
Sam
Guest
Posts: n/a
 
      4th Apr 2005
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

 
Reply With Quote
 
 
 
 
Pipo
Guest
Posts: n/a
 
      4th Apr 2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      4th Apr 2005
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


 
Reply With Quote
 
Sam
Guest
Posts: n/a
 
      4th Apr 2005
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

 
Reply With Quote
 
Pipo
Guest
Posts: n/a
 
      4th Apr 2005
Sam,

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


"Sam" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Sam
Guest
Posts: n/a
 
      4th Apr 2005
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

 
Reply With Quote
 
Pipo
Guest
Posts: n/a
 
      4th Apr 2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sam,
>
> Try:
> added line ---->dsEquivalents.AcceptChanges()
> dsDeleted = dsEquivalents.GetChanges(DataRowState.Deleted)
>
>
> "Sam" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >

>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      4th Apr 2005
Sam,

Did you try that

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

dsDeleted.RejectChanges

dgDeleted.DataSource = dsDeleted

Cor


 
Reply With Quote
 
Sam
Guest
Posts: n/a
 
      4th Apr 2005
Pipo,
I've tried that.
Then dsDeleted' s value is 'Nothing', and doesn't contain any of the
deleted rows in dgEquivalents.

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      4th Apr 2005
Sam,

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

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid delete rows nightmare gepebril Microsoft Dot NET Compact Framework 1 5th Aug 2010 06:10 PM
Delete Rows From DataGrid rn5a@rediffmail.com Microsoft ASP .NET 0 4th Dec 2006 07:18 AM
How to Delete rows from a sorted DataGrid =?Utf-8?B?REJX?= Microsoft C# .NET 0 12th Nov 2004 07:13 PM
Delete mutiple rows in a dataGrid using delete Key =?Utf-8?B?TVZC?= Microsoft Dot NET Framework 0 26th Oct 2004 04:39 AM
Delete rows from DataGrid not working? =?Utf-8?B?Sm9iIExvdA==?= Microsoft Dot NET 0 30th Jul 2004 03:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:10 PM.