Holen Sie sich die ausgewählten drop-down-Liste den Wert aus einer FormCollection in MVC

Ich habe ein Formular Buchung auf eine Aktion, die mit MVC. Ich möchten, ziehen Sie die ausgewählten drop-down-Liste Element aus der FormCollection in der Aktion. Wie mache ich es?

Mein Html-Formular:

<% using (Html.BeginForm())
    {%>
    <select name="Content List">
    <% foreach (String name in (ViewData["names"] as IQueryable<String>)) { %>
          <option value="<%= name %>"><%= name%></option>
    <% } %>
    </select>
    <p><input type="submit" value="Save" /></p>
<% } %>

Meine Aktion:

[HttpPost]
public ActionResult Index(FormCollection collection)
{
    //how do I get the selected drop down list value?
    String name = collection.AllKeys.Single();
    return RedirectToAction("Details", name);
}
Schreibe einen Kommentar