Nov 6th, 2002, 01:13 PM
delete record from database [RESOLVED]
I'm using "e.Index.ItemIndex" to get the row number that was clicked for deletion in my datagrid. How can I obtain the primary key of the row to use in my query to delete the record from the database?
Last edited by EyeTalion; Nov 7th, 2002 at 10:03 AM.
Nov 7th, 2002, 10:02 AM
well, I'm going to answear my own question...hope this helps others..
Set the DataKeyField property of the Datagrid to the name of the primary key. Then on the delete event set a variable to the index of the DataKeyField, example:
Dim ID As Integer = CInt(MyGrid.DataKeys(CInt(e.Item.ItemIndex)))
Then pass this variable into the query or stored procedurer.