I am currently working on a MVC Project and I made following static DropDownBox in a View:
@Html.DropDownList("Art", new List<SelectListItem>
{
new SelectListItem{Text="Orginal Vertrag",Value="Orginal"},
new SelectListItem{Text="Anlage",Value="Anlage"},
new SelectListItem{Text="Kündigung",Value="Kündigung"},
new SelectListItem{Text="Sonstiger",Value="Sonstiges"}
}, "Dokumentenart auswählen")
I want to get the SelectedValue
in a Controller Class. But if I try Art.getSelectedValue()
it underlines the code line. So my Question is how do I get that SelectedValue()
. So could you please help me?
Assuming that you POST a form, you could try to get the selected value like below:
var selectedArt = Request.Form["Art"];
Otherwise if you make a GET request, you should look in the query string parameters.