一、如果后台得到的是一个List类型
1、后台得到数组数据
var dutyList = IOCFactory.R<IEmployeeContract>().BatchFind(m => m.IsDeleted == false && m.IsEnabled == true).Select(m => new { m.EmpID, m.EmpName }).ToList();
ViewBag.dutyList = dutyList;
2、前端循环绑定下拉框
<select class="form-control editable select2_category" name="selEmpID" id="selEmpID">
@foreach (Object item in ViewBag.dutyList)
{
<option value="@item.GetType().GetProperty("id").GetValue(item).ToString()">@item.GetType().GetProperty("name").GetValue(item).ToString()</option>
}
</select>
二、如果后台得到的是一个 List<Employee>类型
1、后台得到对象数组类型
List<Employee> dutyList= IOCFactory.R<IEmployeeContract>().GetListValueByTypeCode(“aa”);
ViewBag.dutyList =dutyList;
2、前端循环绑定下拉框
<select class="form-control editable select2_category" name="RecruitFrom" id="RecruitFrom">
@foreach (var item in ViewBag.admissions_source)
{
<option value="@item.id">@item.name</option>
}
</select>