Updating the Listing Data

Asked

Viewed 59 times

1

I have a small problem, in the image below I have a list of customers. There is a button that opens a modal for editing, it works normal, but after editing the close modal and need to update the list information.

inserir a descrição da imagem aqui

Follow my code below:

 [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Editar(Cliente cliente)
    {
        cliente.Ativo = true;
        try
        {
            using (SistemaDBEntities db = new SistemaDBEntities())
            {
                db.Entry(cliente).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
        catch (Exception ex)
        {

        }
        return RedirectToAction("Index");
    }

Someone knows how to do it?

  • Your Edit Action is being called?

  • You are using Ajax for Modal?

  • Friend if you use Modal recording in Ajax your screen would need to be updated also with Ajax, with Angular or Jquery (indicate Angular) and when receiving from this method the answer that recorded would update the new data, wonder how you do it ?

  • @Cezar I write the data with ajax, which would be the encoding to update via ajax?

  • You load the initial data as?

  • I carry it like this: db.Cliente.First(c => c.Codigo == id)

  • I already solved.... When I ran my ajax I put type as GET and it worked. Thank you all.

Show 2 more comments

1 answer

0

You will have to execute a callback ajax at the completion of the modal edition to update the listing data, otherwise only using redirect to the customers page (refresh).

EDIT: I had not realized that it was in Asp, my resolution would be based on php with this back-end in HTML/javascript.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.