public ActionResult Edit(int id,FormCollection formValues) { // Retrieve existing dinner Dinner dinner = dinnerRepository.GetDinner(id); // Update dinner with form posted values dinner.Title = Request.Form["Title"]; dinner.Description = Request.Form["Description"]; dinner.EventDate = DateTime.Parse(Request.Form["EventDate"]); dinner.Address = Request.Form["Address"]; dinner.Country = Request.Form["Country"]; dinner.ContactPhone = Request.Form["ContactPhone"]; // Persist changes back to database dinnerRepository.Save(); // Perform HTTP redirect to details page for the saved Dinner return RedirectToAction("Details",new { id = dinner.DinnerID }); }
formValues未在方法中使用.它的目的是什么?
解决方法
看看FormCollection的使用方法:
How can a formcollection be enumerated in ASP.NET MVC?