我目前使用 Jtable 来处理事件类型列表,但每次我尝试通过表删除时,我都会收到错误“值不能为空。参数名称:实体”。
[HttpPost]
public JsonResult DeleteEventType(EventType eventType)
{
using (var db = new ICTTBEntities())
{
try
{
var newObj = db.EventTypes.SingleOrDefault(e => e.EventTypeID == eventType.EventTypeID);
if (newObj != null)
{
db.EventTypes.Remove(newObj);
db.SaveChanges();
return Json(new { Result = "OK" });
}
return Json(new { Result = "ERROR", Message = "eventType is null" });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
}
有什么建议吗?