1
設置下拉列表的名稱與可變我想設置dropdown List
名稱與viewbag
值一樣belowe,但回報compile error
着在剃刀
@{
var ControlName = ViewBag.controlname;
}
@Html.DropDownList(ControlName , Model,"please select", new { @class = "form-control" })
,當它改變這一點,其做工精細:
@Html.DropDownList("typename", Model, "please select", new { @class = "form-control" })
'ViewBag'是'dynamic' - 你需要將它轉換爲'string' –