protected void btnAnular_Click(object sender, EventArgs e) { try { List<int> ListaFacturas = new List<int>(); foreach (GridViewRow fila in grdFacturas.Rows) { if (fila.RowType == DataControlRowType.DataRow) { CheckBox chkSeleccionar = (CheckBox)fila.FindControl("chkSeleccionar"); if (chkSeleccionar.Checked) { int IdFactura = int.Parse(this.grdFacturas.DataKeys[fila.RowIndex]["ID_FACTURA"].ToString()); ListaFacturas.Add(IdFactura); } } } if (ListaFacturas.Count == 0) throw new Exception("Debe seleccionar factura"); else { TrxFACTURACION _TrxFACTURACION = new TrxFACTURACION(); _TrxFACTURACION.AnularFacturas(ListaFacturas); Response.Redirect("MensajeExito.aspx?t=Anular Factura&m=Se han anulado las facturas seleccionadas", false); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); panelMensaje.CssClass = "MostrarMensaje"; lblMensaje.Text = ex.Message; return; } }