我的困难是如何使用ViewBag与DropdownListFor?
在我的控制器中,我有:
TestModel model = new TestModel();
ViewBag.Clients = model.Clients;
ViewBag.StatusList = model.StatusList;
ViewBag.enumStatus = model.enumStatus;
ViewBag.intClient = model.intClient;
Run Code Online (Sandbox Code Playgroud)
在我的TestModel中
public SelectList Clients { get; set; }
public SelectList StatusList { get; set; }
public ActiveStatus enumStatus { get; set; }
public int? intClient { get; set; }
Run Code Online (Sandbox Code Playgroud)
在我看来
我想用来DropDownListFor显示ViewBag值,我该怎么做?
我正在寻找一种合理的理念,将动态数据引入视图以填充下拉列表.为下拉列表和其他"开销"数据创建模型对象或使用viewbag是一个好主意吗?
谢谢