Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clean way to delete item on cart 1

Status
Not open for further replies.

matthewking

Programmer
Jul 15, 2002
75
ES
hi all,

i want an x 'button/link' on my datagrid, that posts back and lets me retrieve a value (primary key) associated with it so I can perform the action, namely delete item, is there a way to do this or do i have to create a link? e.g. cart.aspx?action=delete&id=4503
 
You will need to keep track of which index in the datagrid goes to which primary key in the database. When OnItemCommand fires to a handler, it'll need a sender and the event arguments, like so:

void Command_Grid(Object sender, DataGridCommandEventArgs e)

If you look at DataGridCommandEventArgs in documentation, you will find that e.Item.ItemIndex will get you part of the way. If you hit the datatable that you populate the DataGrid with at that index, you should get your primary key.
 
Thanks very much merlyn2450,

Ok, so theres not a direct method of achieving this, do you think it is better to use this approach or the url posting one? e.g. cart.aspx?action=del&id=4

Thanks for the response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top