Get dropdown list value in MVC3 Razor
Please help me to get the selected value of the dropdown list in the controller when i am clicking the submit button.
My view is like
@using (Html.BeginForm())
{
@foreach (var department in @Model)
{
items.Add(new SelectListItem
{
Text = @department.DeptName,
Value = @department.DeptId.ToString()
});
}
@Html.DropDownList("deptID", items, "--Select One--", new { @style = width:160px" }) *
<input type="submit" name="Filter" value="filter" />
}
Please share if you are开发者_JAVA百科 having any website link which explains about the dropdown list and its events in mvc3 Razor.
Thanks San
MVC deals with the binding for you if you have a parameter with the same name
public ActionResult MyAction(string deptID)
{
// whatever
}
精彩评论