Forced conversion of the razor type and forced conversion of the razor type
1. If the background obtains a List type
1. Obtain array data in the background
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. Front-end cyclic binding drop-down box
<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>
2. If the backend obtains a List <Employee> type
1. Obtain the object array type in the background
List <Employee> dutyList = IOCFactory. R <IEmployeeContract> (). GetListValueByTypeCode ("aa ");
ViewBag. dutyList = dutyList;
2. Front-end cyclic binding drop-down box
<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>