我无法使用Viewbag从动态下拉列表中获取ID值,我正在使用存储过程来插入数据。 id的值来自动态下拉列表。
我认为我正在使用
$ unset XAUTHORITY
$ xhost add $DISPLAY . 123f
$ xhost +local:all
$ sudo xclock # or any graphical program needs sudoer
在我的控制器中
@Html.DropDownList("DepartmentID", new SelectList(ViewBag.data, "depId", "depId"), "Department-ID")
答案 0 :(得分:2)
您已将UI字段命名为DepartmentID
:
@Html.DropDownList("DepartmentID", new SelectList(ViewBag.data, "depId", "depId"), "Department-ID")
但是模型上的属性是depId
。您的字段名称需要与绑定它们的模型的属性名称匹配:
@Html.DropDownList("depId", new SelectList(ViewBag.data, "depId", "depId"), "Department-ID")