MVC 4 - remplir dropdownlistfor avec le modèle de liste

Je suis en train de remplir un dropdownlistfor de mon point de vue et je ne sais pas la bonne expression lambda pour qu'il fonctionne. Voir le code ci-dessous:

@model Website.Models.modelTeamSelect


<h2>MatchSelect.cshtml</h2>

@using (Ajax.BeginForm("_PartialTeams",
    new
    {
        model = this.Model
    },
    new AjaxOptions
    {
        HttpMethod = "POST",
        UpdateTargetId = "divMatchScheduler",
        InsertionMode = InsertionMode.Replace
    }))
{

    <div id="divMatchScheduler">
         @Html.LabelFor(m => m.modelMatch.HomeTeam)
         @Html.DropDownListFor(m => m.modelMatch.HomeTeam, new SelectList
    {
      Items = Model.teams.Select(t => t.TeamName)  
    })
         @Html.LabelFor(m => m.modelMatch.AwayTeam)

         @Html.LabelFor(m => m.modelMatch.MatchDate)
         @Html.TextBoxFor(m => m.modelMatch.MatchDate)
    </div>

     <input type="submit" value="Add Match" name="btnSubmit" />


}

Cette syntaxe est mauvaise

@Html.DropDownListFor(m => m.modelMatch.HomeTeam, new SelectList
    {
      Items = Model.teams.Select(t => t.TeamName)  
    })

Mon modèle utilisé par la vue et la collection qu'il contient

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Website.Models
{
    public class modelMatch
    {
       public Guid MatchID { get; set; }

       public Guid AwayTeamID { get; set; }
       public string AwayTeam { get; set; }

       public Guid HomeTeamID { get; set; }
       public string HomeTeam { get; set; }

       public DateTime MatchDate { get; set; }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Website.Models
{
    public class modelTeamSelect
    {
        public modelTeamSelect()
        {
            teams = new List<modelTeam>();
            team = new modelTeam();
            modelMatch = new Models.modelMatch();
            modelMatches = new List<modelMatch>();
        }

        public List<modelTeam> teams { get; set; }
        public modelTeam team { get; set; }
        public modelMatch modelMatch { get; set; }
        public List<modelMatch> modelMatches { get; set; }

        public string message { get; set; }
    }
}

Résumé

Comment dois-je remplir dropdownlistfor à l'aide d'une liste de collection qui est dans mon modèle?

InformationsquelleAutor nick gowdy | 2014-01-20