Click here to Skip to main content
14,328,552 members
Rate this:
Please Sign up or sign in to vote.
See more:

I am trying to delete a row from the table in the shopping cart after selecting several products in the cart page. The products are saved into database through the session.
I have created the delete buttons but they are not working. Can anyone suggest what I should do to make it work.
Is this the right way to add delete button in each row of table cell?

cell = new TableCell();

cell = new TableCell();
Button btn = new Button();
btn.Text = "Delete";
btn.Click += new EventHandler(Delete);

Updated 6-Jun-14 11:25am
j snooze 6-Jun-14 17:16pm
Are you getting an error? Why are you calling Load in the Page_Load? You realize the Page_Load is called every single postback so you are reloading the entire grid even before calling the delete statement. I recommend at least wrapping an if(!IsPostback){Load();} on your Page_Load. otherwise, have you debugged it? Errors? Error trapping?
lolla_zk 6-Jun-14 17:19pm
No actually I never tried this before
j snooze 6-Jun-14 17:39pm
OK, a newbie. Then this might actually be easier. I don't remember all the code you had posted before, but if you add a gridview, you can bind data to it, and it builds itself. Then you can add whats called a template column or command buttons(there are edit, delete command buttons) then you can have the ItemCommand event called by those. Hope this helps.
JoCodes 6-Jun-14 22:33pm
No need to use table. Try using gridview control and command buttons
Good suggestion. Please add this as an answer. :)

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 2

If you are using tablecell rather i would suggest to make an ajax call theough jQuery methodsto delete product. The delete buttn also use some html element like image or link.

Just write a page method to delete the product and call it doing a ajax call.

Reference :-


2. This is an example in php but make ajax call same way in .net as well..:-[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100