2015-08-13 15 views
1

當我選擇編輯鏈接,然後更新記錄。 但是,對象中的字符串字段正在用周圍的引號返回。 我正在使用DevExpressEditorBinder。當使用DevExpressEditorBinder更新數據時,GridView添加了引號

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

將此代碼添加到Global.acax幫助它

protected void Application_Start() 

{ 
    ModelBinders.Binders.DefaultBinder = new DevExpress.Web.Mvc.DevExpressEditorsBinder(); 
} 
相關問題