I m试图使用更新模型(MItem, 表格收集),其编号为p.net mvc 2,但它没有下文中点。
at System.Web.Mvc.FormCollection.GetValue(String name)
at System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties, IValueProvider valueProvider)
at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, IValueProvider valueProvider)
at Stormbreaker.Dashboard.Controllers.DashboardController`1.Update(FormCollection collection) in D:ProjectsSVNStormbreaker runkStormbreaker.DashboardControllersDashboardController.cs:line 23
at lambda_method(ExecutionScope , ControllerBase , Object[] )
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
我的行动就是这样:
[AcceptVerbs(HttpVerbs.Post)]
[ValidateInput(false)]
public ActionResult Update(FormCollection collection) {
UpdateModel(CurrentItem, collection);
CurrentItem = (T)_repository.Update(CurrentItem);
return RedirectToAction("edit", new { pagePath = CurrentItem.UrlSegment });
}
......和我的形式就是这样:
<% using (Html.BeginForm("Update","Dashboard", FormMethod.Post, new { name = "editForm" } )) %>
<% { %>
<div>
<%=Html.EditorForModel() %>
<input type="submit" value="Save" />
</div>
<% } %>