Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,

In my project I have got an actionResult method returning a collection of objects like this:

C#
public ActionResult PartNumberManufacturer(string id)
        {
 
 var partNumber = Context.PartNumberTable.Where(x => x.PartNumberId == id); 
           return PartialView("PartNumberView",    partNumber);
}

How would I iterate my collection abd access each object in the collection??
Sorry I am slighty new to MVC..

Thank you
Posted
Updated 9-Aug-15 22:39pm
v3
Comments
Herman<T>.Instance 10-Aug-15 4:53am    
tried using foreach?

XML
@foreach(var part in Model)
{
    <p>@part.SomeProperty</p>
}


Get a book on MVC or at least go through some tutorials online. A forum is not the best place to learn something from scratch.
 
Share this answer
 
For more understanding,you can view below url:

http://www.c-sharpcorner.com/UploadFile/deveshomar/simple-way-of-binding-list-of-objects-to-view-using-mvc/
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900