I'm trying to use the MVC ViewBag to set an items text dynamically. However I get error messages when I do the following:
items.Add().Text(ViewBag.AppContext.UserDisplayName)
However, if I do something like the below, it works. So I think it has to do with the ViewBag not being available (timing).
items.Add().Text(User.Identity.Name)
Here's the error when I try and use ViewBag data - CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.
Thoughts?
items.Add().Text(ViewBag.AppContext.UserDisplayName)
However, if I do something like the below, it works. So I think it has to do with the ViewBag not being available (timing).
items.Add().Text(User.Identity.Name)
Here's the error when I try and use ViewBag data - CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.
Thoughts?