[英]Cannot perform runtime binding on a null reference in mvc
@if ((ViewBag.DynamicFields.Length == 0 )||((ViewBag.DynamicFields as ICollection<ChampModel.DynamicFields>).Where(o => o.Active == false).Count() == (ViewBag.DynamicFields as ICollection<ChampModel.DynamicFields>).Count()))
{
<div class="info">
@Html.Label("Dynamic fields were not assigned to this table")</div>
}
This error happens when you have a ViewBag property being nonexistent in your view.当您的视图中不存在 ViewBag 属性时,会发生此错误。
See if there is a typo?看看有没有错别字?
or just add check for null或者只是添加检查 null
@if (((ViewBag.DynamicFields == null) ||(ViewBag.DynamicFields.Length == 0 )||((ViewBag.DynamicFields as ICollection<ChampModel.DynamicFields>).Where(o => o.Active == false).Count() == (ViewBag.DynamicFields as ICollection<ChampModel.DynamicFields>).Count()))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.