Datakey in Datagrid

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
 
E

Egbert Nierop \(MVP for IIS\)

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...
 
J

J. Ormaetxe

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
 
E

Egbert Nierop \(MVP for IIS\)

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.
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top