Deleting a row from a dataset using DeleteCommand

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
 
G

Guest

Dan,

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

Kerry Moorman
 
D

DanG

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top