Search Results

Search found 1 results on 1 pages for 'user266909'.

Page 1/1 | 1 

  • asp.net mvc postback

    - by user266909
    I have a controller with the following two Edit methods. The edit form displays correctly with all additional dropdown lists from the FormViewModel. However, when I changed some field values and submitted the form. None of the changed fields were saved. The fields in the postbask collection have default or null values. I have another edit form which update another table. On submit, the changed values are saved. Does anyone know why? // GET: /Transfers/Edit/5 public ActionResult Edit(int id) { Transfer transfer = myRepository.GetTransfer(id); if (transfer == null) return View("NotFound"); return View(new TransferFormViewModel(transfer)); } // // POST: /Transfers/Edit/5 [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, Transfer collection) { Transfer transfer = vetsRepository.GetTransfer(id); if (transfer == null) return View("NotFound"); else { try { UpdateModel(transfer); vetsRepository.Save(); return RedirectToAction("Details", new { id = transfer.TransfersID }); } catch { ModelState.AddModelErrors(transfer.GetRuleViolations()); return View(new TransferFormViewModel(transfer)); } } }

    Read the article

1