-1
我想分配EST_ID
从index.cshtml到Create.cshtml视图,它使用Html.Editorfor(model=>model.EST_ID)
数据EditorFor。如何分配使用TempData的或ViewBag
如何在index.cshtml获得EST_ID
从表分配EST_ID
使用TempData的或ViewBag Html.Editorfor(model=>model.EST_ID)
?
这里是我的控制器代码
public ActionResult Publication(int id)
{
if (ModelState.IsValid)
{
string est = db.EstimateHeaders.Find(id).ToString();
ViewBag.EST_ID=est;
return RedirectToAction("Create", "EP");
}
return View();
}
这里的Create.cshtml代码
@Html.EditorFor(model=>model.EST_ID,
htmlAttributes : new { @placeholder="EST_ID",
@class = "form-control",
@readonly = "readonly",
@required = "required" })
如何从EST_ID
值index.cshtml分配给create.cshtml EditorFor?
我也跟着你的答案,但我正在逐渐'System.Data.Entity.DynamicProxies ....'在视图 –
价值,我改变'字符串EST = db.EstimateHeaders.Find(ID)的ToString( );'to'string est = db.EstimateHeaders.Find(id).EST_ID.ToString();'一切都完美无瑕。谢谢!!! –