[removed] How to iterate through list of objects in Model

前端 未结 4 971
清酒与你
清酒与你 2021-02-14 10:48

so I need to get to fetch the names of students in a list of student object that is in a view\'s model then send them to the server via $.post, the latter I have figured it out

4条回答
  •  伪装坚强ぢ
    2021-02-14 11:38

    Looks like what you need is to output the user names to the client as JSON? Try this:

    var names = @Model.StudentSearchResult.Select(s => new { s.FirstName, s.LastName }).ToList();
    

    I'm not quite familiar with the Razor syntax, but I think you can still understand the code above.

提交回复
热议问题