如何在.cshtml页面中显示详细信息

时间:2018-01-22 11:01:27

标签: asp.net-mvc asp.net-mvc-4

在实现DLL文件时如何在.cshtml页面中显示详细信息

控制器

public ActionResult GetEmpById(int Id)
{
    var x = ObjEmpRepo.GetEmployeesById(Id);
    return View(x);
}

查看

@model Business_Dll.Model.Employee_Model
@foreach (var empDetail in Model)
{   
}

这里的Business_Dll是我的Dll文件。 我得到错误

  

foreach语句无法对“Business_Dll.Model.Employee_Model”类型的变量进行操作,因为“Business_Dll.Model.Employee_Model”不包含“GetEnumerator”的公共定义

1 个答案:

答案 0 :(得分:0)

尝试以下,

@model IEnumerable<Business_Dll.Model.Employee_Model>


@foreach (var empDetail in Model)
{   
}