Andreas
Andreas

Reputation: 533

Best way to implement nested loops in a view in asp.net mvc 2

Trying to implement some nested loops that are spitting out good old nested html table data. So the question is; What is the best way to loop through lists and nested lists in order to produce easily maintainable code. It can get quite narly quite fast when working with multiple nested tables or lists. Should I make use of a HTML helper, or make something with the ViewModel to simplify this?

A requirement is if there are no children at a node there should be an empty row on that spot with some links for creation and into other parts of the system.

Upvotes: 0

Views: 365

Answers (1)

Robaticus
Robaticus

Reputation: 23157

Assuming you're working with nice strongly-typed data, I would go with a number of partial views to get this done. I did something similar with a project I worked on, and it made understanding the code and maintaining the code quite easy.

Upvotes: 1

Related Questions