View not updating after post

杀马特。学长 韩版系。学妹 提交于 2019-11-27 07:34:44
Mason

it should be the ModelState problem. if you use Htmlhelper to Display id value. Default HtmlHelper display ModelState value not Model. Try display model value in view

<td>
    @Model.id
</td>

or Clean ModelState Value in controller

ModelState.Clear();

or reset id value after SaveChange.

theCar.Save();
ModelState["id"].Value = theCar.id
return View(theCar);

Reset the value of textarea after form submission

Captain0

I didn't want to clear the ModelState because I needed to display errors, so I went with

ValueProviderResult vpr = new ValueProviderResult("", null, System.Globalization.CultureInfo.CurrentCulture);

ModelState["id"].Value = vpr;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!