private void RunGridViewRowCommand(string commandName, object commandArgument) { int result = 0; // get data key DataKey dk = gvCustomersPayments.DataKeys[Convert.ToInt32(commandArgument)]; // check data key if (dk == null) { return; } // get payment int paymentId = (int)dk.Value; // run command switch (commandName) { case "Approve": result = StorehouseHelper.ChangeCustomerPaymentStatus(paymentId, TransactionStatus.Approved); break; case "Decline": result = StorehouseHelper.ChangeCustomerPaymentStatus(paymentId, TransactionStatus.Declined); break; case "Remove": result = StorehouseHelper.DeleteCustomerPayment(paymentId); break; } // show error if (result < 0) { ShowResultMessage(result); return; } // re-bind data gvCustomersPayments.DataBind(); }