当我选择编辑链接然后更新记录时。 但是,对象中的字符串字段返回时带有引号。 我正在使用DevExpressEditorBinder。
public ActionResult GridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] DevExpressMvc.Models.Employee item)
{
var model = db.Employees;
if (ModelState.IsValid)
{
try
{
var modelItem = model.FirstOrDefault(it => it.id == item.id);
if (modelItem != null)
{
this.UpdateModel(modelItem);
db.SaveChanges();
}
}
catch (Exception e)
{
ViewBag.EditError = e.Message;
}
}
else
ViewBag.EditError = "Please, correct all errors.";
return PartialView("_GridViewPartial", model.ToList());
}
答案 0 :(得分:0)
将此代码添加到Global.acax帮助它
protected void Application_Start()
{
ModelBinders.Binders.DefaultBinder = new DevExpress.Web.Mvc.DevExpressEditorsBinder();
}