I have a ViewModel and a ReadOnly Property in that view model that I can't seem to access in the view.
Public ReadOnly Property ListOfSubjects() As List(Of ListOfSubjects)
Get
Return FeedbackSubjectsContract.GetList()
End Get
End Property
The problem is that in my view when I attempt to loop through the "ListOfSubjects" I am getting "Object reference not set to instance of the object"
The Controller looks like this
Function Index() As ActionResult
Return View()
End Function
The View looks like this:
<%
For Each myItem In Model.ListOfSubjects
Response.Write(myItem.SubjectName))
Next
%>
Also, the view is strongly typed and inherits the correct Model. Actually, I can set that property in the controller okay and return a newly-initialized model to my view and that works okay but I can't seem to set the value of that list in my model (which is where I would like to do it)
What am I doing wrong?