Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

How do I delete the current record?

I have a DataSet which contains a "products" table which is viewed in a DataGrid.

I would like to provide a Delete button, which should delete the current record, as seen in the grid.

I have no idea how to do this. Let's say I issue this command:


The first record delete works ok, but the next record deletes seem to be messed up... the wrong row gets deleted. :-(

I'm kind of disappointed. This is a 15-seconds task in Delphi.

How do I do it using C#?

I'm not asking for much - all I want is provide a delete record button which works on the current record, as seen in the grid!


John K.
Sunday, June 29, 2003

You can use dataSet11.products.Rows(e.Item.ItemIndex).Delete() in DataGrid Delete event

Arpan shukla
Tuesday, July 1, 2003

There's a topic on this in the docs, if that helps, at

mike pope
Wednesday, July 2, 2003

> You can use dataSet11.products.Rows
> (e.Item.ItemIndex).Delete() in DataGrid Delete event

Thank you, but I tried that, and it doesn't work.

I have used a SqlCommand component (or something) to issue a "DELETE FROM tablename" command.

It worked!

John K.
Wednesday, July 2, 2003

*  Recent Topics

*  Fog Creek Home