I have two models below.
public class CustMaster
{
public string FirstName { get; set; }
public string LastName { get; set; }
public List<DetailsInfo> GetDetails { get; set; }
}
public class DetailsInfo
{
public string OrderId { get; set; }
public string OrderDescription { get; set; }
public string OrderStatus { get; set; }
public string Price { get; set; }
}
I use this model in my view to display the result in my html section
@model IEnumerable<Tester.Domain.GenClasses.CustMaster>
Data is returned in this format
Row 0
-FirstName
-LastName
-GetDetails
-Row 0
-OrderId
-OrderDescription
-OrderStatus
-Price
-Row 1
-OrderId
-OrderDescription
-OrderStatus
-Price
Row 1
-FirstName
-LastName
-GetDetails
-Row 0
-OrderId
-OrderDescription
-OrderStatus
-Price
-Row 1
-OrderId
-OrderDescription
-OrderStatus
-Price
I want to be able to display data in my html i.e loop through the entire main list and write out the inner data. I am thinking it should be like the code below. Is this correct? What will the parent foreach look like? Will this be a foreach or a for statement? Please assist.
@foreach(what goes here?)
{
@foreach (var m in CustMaster)
{
<ul>
<li>
</li>
@foreach (var d in m.GetDetails)
{
<li>
<ul>
<li> </li>
<li> </li>
<li> </li>
<li> </li>
</ul>
</li>
}
</ul>
}
}
foreachstatement works on objects that implements aIEnumerableinterface. Then the answer is .. it depends on how the collections ofCustMasterobjects is defined.