Datakey in Datagrid

  • Thread starter Thread starter J. Ormaetxe
  • Start date Start date
J

J. Ormaetxe

Hello,

I am developing a Datagrid thar insert, delete and update rows in a Table.
This table has got 2 fields that are primary key. How can i detect which row
is selected to delete??
Thanks,

Asier
 
J. Ormaetxe said:
Hello,

I am developing a Datagrid thar insert, delete and update rows in a Table.
This table has got 2 fields that are primary key. How can i detect which row
is selected to delete??
Thanks,
Hi!
By implementing the onitemdelete event.
private void yourgrid_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{




}

parameter e contains both datakeys and command data...
 
Thanks, but i dont'n know what is exactly the sentence to write.
Can you write an example of this event please??

Thanks a lot
 
J. Ormaetxe said:
Thanks, but i dont'n know what is exactly the sentence to write.
Can you write an example of this event please??

private void yourGrid_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

int key = (int)yourGrid.DataKeys[e.Item.ItemIndex];

}

Of course, this only works if you have defined the primary key at design.
 
Back
Top