I\'m trying to generate a table in a razor view using reflection to pull the properties from the model.
Here is what I\'ve tried:
@if (@Model.Count() &
If you dont really need the DisplayFor method, you can do it like this in your loop:
@foreach (PCNWeb.Models.Switch item in Model) { /*System.Reflection.PropertyInfo[]*/ properties = item.GetType().GetProperties(); @foreach (var property in properties) { @property.GetValue(item,null) } }