난 당신이 모든 현재 FitToPlay 플레이어를 통해 경우 이동 각각의 위치를 통해 루프를 원하는 루프 내부 것이라고 생각하거나 자신의 첫 번째 또는 보조 위치는 현재 다음에 그를 삽입 위치를 통해 반복된다. . 결국 누군가가 .. 뭔가 같은
드롭 다운리스트를 만들 삽입 된 경우
//Loop through all the positions
foreach (var position in Model.positions)
{
//Create a list for each position
List<SelectListItem> playersInPosition = new List<SelectListItem>();
//Only loop through players with the current position as either primary or secondary
foreach(var player in Model.FitToPlay.Where(pl => pl.primary == position || pl.secondary == position))
{
//Put this player into the list
playersInPosition.add(new SelectListItem { Text = player.name, Value = player.id});
}
//If at least one fits the criteria make a drop down list from it
if(playersInPosition != null && playersInPosition.Count > 0)
{
@Html.DropDownList(position.name, playersInPosition);
}
}