Deleting a row from a dataset using DeleteCommand

  • Thread starter Thread starter DanG
  • Start date Start date
D

DanG

I do not want to delete the row from the database when the user clicks
"delete" on the datagrid. I want to mark the dataset record as
deleted, and let the DataAdapter call the delete sproc when the "save"
button is clicked.

In the datagrid1_deletecommand function, .NET returns e.item, which
points to the DATAGRID row. How do I get a pointer to the DATASET row
that was used to create the grid row?

I can't use the e.Item.ItemIndex, because it doesn't account for
previously deleted records. I thought perhaps the e.Item.DataItem
sounded right, but it comes back null.

tia
Dan
 
Dan,

By default, everything should already be working exactly the way you say you
want it work.

Kerry Moorman
 
I would have expected things to work as expected, but they don't seem
to. Here's what I see:

Let's say there are two rows in the dataset, A and B. They display in
the grid as rows 0 and 1. If the user clicks to delete row 0, the
datagrid1_deletecommand e.item.itemindex returns 0, and I mark A as
"deleted". After the next databind, B is now in the grid at row 0.
Again, the user clicks to delete. I hoped the itemindex would come
back as 1, but it's again 0. Dataset row 0 (A) is already deleted. I
don't want A. I want B.

At that point, what connects grid row 0 to dataset row B?

Dan
 
Back
Top