In Teilansicht Ich arbeite mit Textfeldern wie diesem.MVC Razor Radio Button
@model Dictionary<string, string>
@Html.TextBox("XYZ", @Model["XYZ"])
Wie kann ich Radiobuttons erzeugen, und den gewünschten Wert in Form Sammlung als JA/NEIN True/False erhalten)? Zur Zeit bekomme ich null für "ABC", wenn ich irgendeinen Wert für das Folgende wähle.
<label>@Html.RadioButton("ABC", @Model["ABC"])Yes</label>
<label>@Html.RadioButton("ABC", @Model["ABC"])No</label>
-Controller
public int Create(int Id, Dictionary<string, string> formValues)
{
//Something Something
}
zeigen auch Ihre Aktion-Methode Code. –
mögliches Duplikat von [ASP.NET MVC Ja/Nein-Optionsfelder mit stark gebundenem Modell MVC] (http://stackoverflow.com/questions/2559208/asp-net-mvc-yes-no-radio-buttons-with-strongly -bound-model-mvc) –