I have a Model containing many rows. One of the columns in the row shows the datastore location. What I would like to do is to have a table of data for each datastore location. Is there some simple way I could do this with Razor? Here’s a simplified example of what I have.
<table>
@foreach (var item in Model) {
<tr>
<td>@item.Datastore</td>
<td>@item.xxx</td>
<td>@item.yyy</td>
</tr>
}
</table>
If you haven’t got the list of individual data sources available to you in your model you will have to extract them directly from you model. You can do this using Linq and using the Distinct method to find the unique values.
Once you have those you can then loop through the list and create individual table for each data store and populate them using filtered values from your model based on the data store value.
Something like this should work: