1

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 having any website link which explains about the dropdown list and its events in mvc3 Razor.

Thanks San

san
  • 1,859
  • 4
  • 26
  • 38

1 Answers1

3

MVC deals with the binding for you if you have a parameter with the same name

public ActionResult MyAction(string deptID) 
{
    // whatever
}
fearofawhackplanet
  • 52,166
  • 53
  • 160
  • 253