示例#1
0
        protected void datosClientes_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Editar")
            {
                int         indice = Convert.ToInt32(e.CommandArgument);
                GridViewRow fila   = datosClientes.Rows[indice];

                txtid.Text            = fila.Cells[0].Text;
                txtNombrePersona.Text = fila.Cells[1].Text;
                txtApellido.Text      = fila.Cells[2].Text;
                txtEdad.Text          = fila.Cells[3].Text;
                btnGuardar.Text       = "Actualizar";
                btnGuardar.CssClass   = "btn btn-primary";
            }
            else if (e.CommandName == "Eliminar")
            {
                int         indice = Convert.ToInt32(e.CommandArgument);
                GridViewRow fila   = datosClientes.Rows[indice];
                persona.gsIdPerson = int.Parse(fila.Cells[0].Text);
                int resultado = persona.EliminarCliente();
                if (resultado > 0)
                {
                    Listar();
                    PanelAlerta.Visible = true;
                }
                else
                {
                    pnlAlertaError.Visible = true;
                }
            }
        }