Reputation: 253
@Html.DropDownList("CourseField", new SelectList(SmartJob.Web.UI.Helper.ProfessionalCourseDropDownHelper.CourseCategoriesDropDown, "Key", "Value", 0), "Field of Study")
I want to pass the selected record as a parameter to a method in my contoller. How can I pass that value?
This is the method in my controller.
public PartialViewResult SearchCourseCriteria(string CourseField){
}
Upvotes: 2
Views: 1216
Reputation: 12491
If you use form post like this:
<form method="get" action="/YourController/SearchCourseCriteria">
@Html.DropDownList("CourseField", new SelectList(SmartJob.Web.UI.Helper.ProfessionalCourseDropDownHelper.CourseCategoriesDropDown, "Key", "Value", 0), "Field of Study")
<button>Submit<button />
<form />
Then your controller will be like this:
public PartialViewResult SearchCourseCriteria(string CourseField)
{
...//Controller logic here
}
Depending on your value
type in DropDown it could be not string
, but int
or anythig else...
Upvotes: 1