我在Mvc应用程序中遇到错误 [英] Iam getting Error in Mvc Application
本文介绍了我在Mvc应用程序中遇到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@ {
ViewBag.Title =Index;
Layout =〜/ Views / Shared / _Layout.cshtml;
}
索引
@foreach(ViewBag.name中的var Employee)//此行中的错误
{
@ Employee.EmpID
@ Employee.Empname
};
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
Index
@foreach (var Employee in ViewBag.name)// Error in this line
{
@Employee.EmpID
@Employee.Empname
};
推荐答案
显然你不能设置name
ViewBag
从不...所以它是null
而且不能枚举
通过foreach
...
It is obvious that you din't setname
property ofViewBag
never...So it isnull
and for that can not beenumerated
byforeach
...
这篇关于我在Mvc应用程序中遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文