我有下面的模型說F:可枚舉對象MVC4
public partial class F
{
[Key, Display(Name = "Id")]
public int FId { get; set; }
public int RId { get; set; }
public int FTId { get; set; }
public string C { get; set; }
public string U { get; set; }
public string D { get; set; }
[ScaffoldColumn(false)]
public System.DateTimeOffset Created { get; set; }
}
在控制器我必須從數據庫中讀取的「F」的所有記錄,並指定那些記錄的一個枚舉列表。
對於前:
ViewBag.Cs = enumerable C column items (textbox)
ViewBag.Us= enumerable U column items (textbox)
ViewBag.FTIDs = enumerable FTId column items (this has to be a dropdown)
在我我必須表明
@Html.Textbox(Cs);
@Html.Dropdown(FTIDs);
我只給了文本框和dropdows作爲一個例子,有可能像日期時間,複選框等許多其他控件, 我應該能夠將每列寫入viewbag列表並在MVC視圖中顯示它。
有人可以建議,如果這可以實現和如何?
非常感謝......