I have a form that a user can fill out x times with the data they want. The form is submitted for the next action.
[HttpPost] public ActionResult Manage(ProductOptionModel DataToAdd) { if (!ModelState.IsValid) { return View(DataToAdd); } var ProdServ = new ProductService(); if (DataToAdd.ID != 0) { //Edit Mode. DataToAdd = ProdServ.EditProductOption(DataToAdd); ViewData["Message"] = "Option Changes Made"; }else { //Add DataToAdd = ProdServ.AddProductOption(DataToAdd); ViewData["Message"] = "New Option Added"; } var RetModel = new ProductOptionModel() {ProductID = DataToAdd.ProductID}; return View(RetModel); }
So, below, I shade the model (leaving only the required field), and then return to the view. However, the view contains data from a previously submitted form.
Any ideas why? I debugged the code and checked that the RetModel variable is empty.
source share