save changes problem

Posted by ognjenb on Stack Overflow See other posts from Stack Overflow or by ognjenb
Published on 2010-05-07T08:20:25Z Indexed on 2010/05/07 8:28 UTC
Read the original article Hit count: 207

Filed under:
|
   // GET: /Transporter/Edit/5

    public ActionResult Edit(int id)
    {
        var FilesQueryEdit = (from i in FilesEntities.transporter
                          where i.Id == id
                          select i).First();

        return View(FilesQueryEdit);
    }

    //
    // POST: /Transporter/Edit/5

    [HttpPost]
    public ActionResult Edit(int id, transporter trn)
    {
        try
        {
            // TODO: Add update logic here

            FilesEntities.AddTotransporter(trn);
            FilesEntities.SaveChanges();

            return RedirectToAction("Transporters");
        }
        catch
        {
            return View();
        }
    }

This code inserts new row after post edited data. How to modify post action result to save changes in edited row without inserting new row

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mvc