Templates can be used only with field access, property access, single-dimension array index error
You can't use DisplayFor
because the expression can't leverage that extension method, you just use the raw value:
@objclasstime.ReturnPersianDay(int.Parse(item.ClassDay))
instead of:
@Html.DisplayFor(modelItem => objclasstime.ReturnPersianDay(int.Parse(item.ClassDay)))
If you want to use a method with DisplayFor
, just store the value in a variable before using it.
You had
@Html.DisplayFor(modelItem => objclasstime.ReturnPersianDay(int.Parse(item.ClassDay)))
Instead, try this
var persianDay = bjclasstime.ReturnPersianDay(int.Parse(item.ClassDay));
@Html.DisplayFor(m => persianDay)