我无法弄清楚为什么我的视图只将模型的NULL传回给我的控制器.这适用于Edit Post方法.我使用Edit Post方法检查了其他控制器,其结构与此相同,并且它们工作正常.它似乎只是这个视图和控制器.
这是我的观点:
@model Non_P21_Quote_System_v1._0.Models.gl_code
@{
ViewBag.Title = "Edit";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Edit</h2>
@if (TempData["Message"] != null)
{
<div style="color:green">
@TempData["Message"]
</div><br />
}
@if (ViewBag.error != null)
{
<div style="color:red">
<h3>@ViewBag.error</h3>
</div><br />
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>gl_code</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.ID)
<div class="form-group">
@Html.LabelFor(model => model.GL_code, "GL Code", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.GL_code, new { htmlAttributes …Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×1