protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { ECommerceService proxy = new ECommerceService(); GridViewRow row = GridView1.Rows[Convert.ToInt32(e.CommandArgument)]; int productid = Convert.ToInt32(row.Cells[0].Text); if (e.CommandName == "RemoveItem") { proxy.RemoveItem(Session["cartid"].ToString(), productid); } if (e.CommandName == "UpdateItem") { int qty = Convert.ToInt32(((TextBox)row.FindControl("TextBox2")).Text); if (qty <= 0) { throw new Exception("Quantity must be greater than 0"); } proxy.UpdateItem(Session["cartid"].ToString(), productid, qty); } GridView1.DataBind(); DisplayTotal(); }