Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 18, 2012 03:37 PM by Unnics
Jun 18, 2012 03:23 PM|LINK
I have a class file (Facility.vb) in my MVC project root containing a single class (Facility). One of the properties of my ViewModel which I pass to the View is a List(Of Facility).
In my View, I iterate through each Facility like so:
@For Each f As Object In Model.Facilities
This works fine but if I use Facility instead of Object then it tells me it is undefined.
I would appreciate it if someone could point me in the right direction!
Jun 18, 2012 03:26 PM|LINK
@For Each f As Facility In Model.Facilities
@For Each f In Model.Facilities
Jun 18, 2012 03:31 PM|LINK
Thank you for the quick reply - the first one was what I was using and getting the error.
I didn't think to try it without a datatype but that has done the trick.
Why would I not be able to use @For Each f As Facility In Model.Facilities ?
Jun 18, 2012 03:37 PM|LINK
Hi you can use the fully qualified name space to get the reference of your class in the view.
If the class "Facility " is in the name space "ABC",
then you will be able to get the referenece by ABC.Facility
so that you will be able to
@For Each ABC.Facility f In Model.Facilities
Hope this will help.