Wednesday, April 25, 2018

nested foreach loops for List properties

OK, I have a list of objects, whose properties include a list of another type of object. let's call it List<Quote> Quotes, and the Quote object has a property List<Item> Items.

I'm trying to show these items with a foreach loop...

@foreach(var quote in Quotes)

{

<div class="row">

//Some content for each property and

@foreach(var item in quote.Items)

{

//some content for each item within the Items list

}

</div>

}

I'm getting this super strange error

Blurred out some identifiable information.

When I take out that second foreach loop and "test" in it's place, the error goes away and the page renders no problem.

Can you not put a foreach loop for a list property inside a foreach loop for a list?

nested foreach loops for List properties Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team