我在解决这个问题上遇到了一些问题。问题是,这是它唯一无法工作的地方,在我项目的其他任何地方它运作得很好而且它都是一样的。
这是我的链接:
<td class="col-sm-1 col-lg-1">@Html.ActionLink("Edit", "EditGrowWeek", "FinishedProductionMaintanance", new { @id = Model.growWeek.GWID }, new { @data_toggle = "modal", @data_target = "#editGrowWeek" })</td>
我的控制员:
[HttpGet]
public ActionResult EditGrowWeek(int id)
{
viewModel.growWeek = _ProductionGrowWeekRepository.GetOne(id);
return PartialView(viewModel);
}
[HttpPost]
//[ValidateAntiForgeryToken]
public ActionResult EditGrowWeek([Bind(Prefix="growWeek")] ProductionGrowWeek growWeek)
{
var growWeeks = _ProductionGrowWeekRepository.GetAll(growWeek.GProfileNo);
foreach (var week in growWeeks)
{
if (ModelState.IsValid)
{
_ProductionGrowWeekRepository.Edit(week);
}
}
return RedirectToAction("IndexGrowProfiles");
}
最后我的观点:
@model SISCOM.ViewModel.FinishedProductionMaintananceViewModel
@{
Layout = null;
}
<div class="modal fade in" id="editGrowWeek" tabindex="-1" role="dialog" aria-labelledby="MyModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dissmiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
@using (Html.BeginForm("EditGrowWeek", "FinishedProductionMaintanance", FormMethod.Post))
{
@*@Html.AntiForgeryToken()*@
<form id="form">
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.growWeek.GWID)
@Html.HiddenFor(model => model.growWeek.CutSupplierCode)
@Html.HiddenFor(model => model.growWeek.DelvyWk)
@Html.HiddenFor(model => model.growWeek.Description_ID_)
@Html.HiddenFor(model => model.growWeek.Description_Product_)
@Html.HiddenFor(model => model.growWeek.Despatch)
@Html.HiddenFor(model => model.growWeek.FinishedDuration)
@Html.HiddenFor(model => model.growWeek.FinishedSite)
@Html.HiddenFor(model => model.growWeek.GapUpHandSite)
@Html.HiddenFor(model => model.growWeek.GapUpMCSite)
@Html.HiddenFor(model => model.growWeek.GerminationDuration)
@Html.HiddenFor(model => model.growWeek.GerminationSite)
@Html.HiddenFor(model => model.growWeek.Germinator)
@Html.HiddenFor(model => model.growWeek.GerminatorDuration)
@Html.HiddenFor(model => model.growWeek.GerminatorSite)
@Html.HiddenFor(model => model.growWeek.GProfileNo)
@Html.HiddenFor(model => model.growWeek.GrowWks1)
@Html.HiddenFor(model => model.growWeek.GrowWks2)
@Html.HiddenFor(model => model.growWeek.GrowWks3)
@Html.HiddenFor(model => model.growWeek.GrowWks4)
@Html.HiddenFor(model => model.growWeek.GrowWks5)
@Html.HiddenFor(model => model.growWeek.OrderWK)
@Html.HiddenFor(model => model.growWeek.PreGapDuration)
@Html.HiddenFor(model => model.growWeek.PreGapSite)
@Html.HiddenFor(model => model.growWeek.PrickOut)
@Html.HiddenFor(model => model.growWeek.PrickOutSite)
@Html.HiddenFor(model => model.growWeek.Priority)
@Html.HiddenFor(model => model.growWeek.ProdGrp)
@Html.HiddenFor(model => model.growWeek.ProdSeries)
@Html.HiddenFor(model => model.growWeek.ProdSeriesDetail)
@Html.HiddenFor(model => model.growWeek.ProductionGrowProfile)
@Html.HiddenFor(model => model.growWeek.RangeUpdateFlag)
@Html.HiddenFor(model => model.growWeek.Rooting_GermAssess)
@Html.HiddenFor(model => model.growWeek.SiteGrown)
@Html.HiddenFor(model => model.growWeek.SiteRange)
@Html.HiddenFor(model => model.growWeek.SiteSown)
@Html.HiddenFor(model => model.growWeek.Topping)
@Html.HiddenFor(model => model.growWeek.ToppingCode)
@Html.HiddenFor(model => model.growWeek.Transplant)
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.WksToDesp, "Weeks to despatch")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.WksToDesp, null, new { @class = "form-control", @placeholder = "Weeks to despatch" })
@Html.ValidationMessageFor(p => p.growWeek.WksToDesp, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.GapUp, "Gap up")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.GapUp, null, new { @class = "form-control", @placeholder = "Gap up" })
@Html.ValidationMessageFor(p => p.growWeek.GapUp, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Pinch1, "Pinch1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Pinch1, null, new { @class = "form-control", @placeholder = "Pinch1" })
@Html.ValidationMessageFor(p => p.growWeek.Pinch1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Pinch2, "Pinch2")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Pinch2, null, new { @class = "form-control", @placeholder = "Pinch2" })
@Html.ValidationMessageFor(p => p.growWeek.Pinch2, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space1, "Space1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space1, null, new { @class = "form-control", @placeholder = "Space1" })
@Html.ValidationMessageFor(p => p.growWeek.Space1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space2, "Space2")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space2, null, new { @class = "form-control", @placeholder = "Space2" })
@Html.ValidationMessageFor(p => p.growWeek.Space2, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Space3, "Space3")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Space3, null, new { @class = "form-control", @placeholder = "Space3" })
@Html.ValidationMessageFor(p => p.growWeek.Space3, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(p => p.growWeek.Check1, "Check1")
</div>
<div class="editor-field">
@Html.TextBoxFor(p => p.growWeek.Check1, null, new { @class = "form-control", @placeholder = "Check1" })
@Html.ValidationMessageFor(p => p.growWeek.Check1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Edit" class="btn btn-default" />
</div>
</div>
</form>
}
</div>
</div>
</div>
</div>
我到处检查,这个人根本没有打电话......任何想法?
P.S。 ...这可能是连接的,所以,在这个页面上,(在渲染这部分的索引上)我的页脚正在代码中的页面中间某处呈现..
答案 0 :(得分:0)
这并没有多大意义,但现在确实如此。问题是,每当我为该表生成值时,由于某种原因,它会删除跟随它的部分视图(如果有人能理解这种行为并且可以解释请做。)
所以,我的这个页面的索引看起来像这样:
<div class="tab-content col-md-9 col-lg-9 growProfilePage">
<div class="col-md-12 col-lg-12">
<div class="col-md-4">
@{ Html.RenderPartial("ListGrowProfiles");}
</div>
<div class="col-md-8">
@{ Html.RenderPartial("ListGrowWeeks");}
@{ Html.RenderPartial("EditGrowWeek");}
</div>
</div>
</div>
现在看起来像这样:
<div class="tab-content col-md-9 col-lg-9 growProfilePage">
<div class="col-md-12 col-lg-12">
@{ Html.RenderPartial("EditGrowWeek");}
<div class="col-md-4">
@{ Html.RenderPartial("ListGrowProfiles");}
</div>
<div class="col-md-8">
@{ Html.RenderPartial("ListGrowWeeks");}
</div>
</div>
</div>
这一切都有效(奇怪的是,在其他页面上它仍然像以前一样,编辑跟在列表之后,就像那样)。