我一直在四处寻找,但没有运气。
我想要做的是传递登录人员的UserId,我已经在我的模型中使用了UserID。我有下面的代码,需要传入UserID而不是last_update_by_IN。
<div class="form-group">
@Html.LabelFor(model => model.last_update_by_IN, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.last_update_by_IN)
@Html.ValidationMessageFor(model => model.last_update_by_IN)
</div>
</div>
我试过
<div class="form-group">
@Html.LabelFor(model => model.last_update_by_IN, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserID)
@Html.ValidationMessageFor(model => model.last_update_by_IN)
</div>
</div>
但是这显示了正确的UserID,但是将0传递给了数据库。如果我需要澄清更多内容,请告诉我。感谢
这是我控制器中的帖子,忘记添加此抱歉
public ActionResult Edit([Bind(Include="column names here")] User_Accounts user_accounts)
{
if (ModelState.IsValid)
{
db.Entry(user_accounts).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.user_type_id_IN = new SelectList(db.User_Type, "userId", "userType", user_accounts.user_type_id_IN);
ViewBag.userId = new SelectList(db.Userinfo, "userId", "pinId", user_accounts.user_id_IN);
return View("Edit", user_accounts);
}