[HttpPost]
public ActionResult Index(SecurityMappingModel objModel)
{
//edit code
if (objModel.Id != Guid.Empty)
{
if (ModelState.IsValid)
{
mappings = (List<SecurityMappingModel>)Session["Mappings"];
var objRemove = mappings.FirstOrDefault(m => m.Id == objModel.Id);
if (objRemove != null)
{
mappings.Remove(objRemove);
mappings.Add(objModel);
ViewBag.Mappings = mappings;
}
Session["Mappings"] = mappings;
return RedirectToAction("Index");
}
內部objModel由具有該字段值0,因爲它是一個文本字段我把值插入,但控制器oject objModel內示出的字段值中的一個是零:(:(爲什麼???在編輯mvc3中的webgrid時,爲什麼ModelState.IsValid爲false,因爲條件爲真?
你能告訴我們什麼'SecurityMappingModel'看起來像,並向我們展示您的視圖嗎? – 2012-04-19 16:37:35