ASP.NET Core 1.0 POST IEnumerable to controller

后端 未结 2 1265
既然无缘
既然无缘 2020-12-19 12:40

I have an action that returns a model to the View which is IEnumerable. In the view I loop through the list using foreach. T type has a property called

2条回答
  •  失恋的感觉
    2020-12-19 12:53

    The problem was @model IEnumerable in the view. I changed that to List and use instead a for loop:

    @model List
    
    
    
    @for (int i = 0; i < Model.Count(); i++) {
    @Model[i].Title
    }

    SAVE

提交回复
热议问题