martes, 26 de julio de 2016

C# - El método seleccionado no es compatible (ej: RowUpdating)


.ASPX
 function EndCallGrid(s, e) {
            if (s.cpError != null && s.cpError == 'true') {
                eval(s.cpMensaje);
                s.cpError = null;
                s.cpMensaje = null;
            }

            if (s.cpError != null && s.cpError == 'false') {
                if (eval(s.cpMensaje)) {
                    ASPxCallbackForm.PerformCallback('ACT');
                }
                s.cpError = null;
                s.cpMensaje = null;
            }
//Gatilla PerformCallback para refrescar grilla
            if (s.cpError != null && s.cpError == 'R') {
                gvDetPago.PerformCallback('REFRESH');
                s.cpError = null;
            }
        }

.CS


void gvDetPago_RowUpdating(object sender, ASPxDataUpdatingEventArgs e)
        {
            var data = (List<BePagos>)HttpContext.Current.Session["PagoDetalle"];
            if (data != null && data.Count > 0)
            {
                var item = data[gvDetPago.FocusedRowIndex];
                item.fecha_pago = Convert.ToDateTime(Session["fecha_pago"]);
                MapItem(e.NewValues, e.OldValues, item, ref data);

            }
            HttpContext.Current.Session["PagoDetalle"] = data;

          //en el endCallback de la grilla gatillo refresco
            ((ASPxGridView)sender).JSProperties["cpError"] = "R";

            //Termina la Edición de la grilla manualmente.-
            e.Cancel = true;                    
            ((ASPxGridView)sender).CancelEdit();
        }



  void gvDetPago_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            if (e.Parameters.ToUpper() == "EVALUAR")
            {
                Evaluar(ref sender);
            }
            if (e.Parameters.ToUpper() == "ADD")
            {
                Session["tipo_cuota"] = null;
                Session["cod_concepto"] = "1";
                var fecha = gvDetPago.VisibleRowCount > 0
                                ? Convert.ToDateTime(gvDetPago.GetRowValues(0, "fecha_pago") ?? DateTime.Now)
                                : DateTime.Now;
                Session["fecha_pago"] = new DateTime(fecha.Year, fecha.Month, fecha.Day);
                Session["oper"] = gvDetPago.VisibleRowCount > 0 ? gvDetPago.GetRowValues(0, "operacion") : "0";
                Session["tipo_cuota"] = "0";


                AddNewRow(ref sender);
                gvDetPago.Selection.UnselectAll();
                gvDetPago.Selection.SelectRow(gvDetPago.VisibleRowCount - 1);
                gvDetPago.DataBind();
                Session["FocusedRowIndex"] = gvDetPago.VisibleRowCount - 1; //se captura el foco en session para evitar perdida del mismo cuando el usuario cambia de control  editable en el row
            }
            if (e.Parameters.ToUpper() == "REFRESH")
            {
//si la session no es nula vuelvo a pintar la grilla.-
                if (Session["PagoDetalle"] != null)
                {
                    gvDetPago.DataSource = Session["PagoDetalle"];
                    gvDetPago.DataBind();
                }
            }
        }

No hay comentarios:

Publicar un comentario