How to pass string value of MVC DropDownList as a parameter to method in controller?

Sumudu De Zoysa
 @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){

}
teo van kot

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...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to pass dropdownlist selected value to get function in controller in mvc

How to pass value selected from DropDownList to Controller - MVC

How to Pass Kendo DropDownList DataTextField value to Controller

How to pass a null value for a URL parameter to Spring MVC controller?

How to by pass value of dropdownlist to event onchange in MVC ?

How to pass value of particular row to controller method in asp .net mvc

Pass selected value dropdownlist to controller

How to pass a div element as a parameter to an MVC controller?

how to get dropdownlist value and pass to controller via ActionLink?

How can I pass the value of dropdownlist from view to controller?

pass the selected value of Html.DropDownList to controller

JQGrid: Pass JQGrid column value as a parameter to controller method specified in cellurl

Spring MVC How take the parameter value of a GET HTTP Request in my controller method?

Pass dropdownlist value from View to Controller in Asp.Net MVC4 without using jquery or javascript?

How to pass a String parameter to a void method?

How to pass string value from WidowsForm to ASP.NET MVC Controller

MVC 4 Dropdownlist Pass value by button?

Pass query string parameter to UrlHelper.Action method in .net mvc

How to pass a object parameter to the controller Spring mvc by an onclick

How to pass a parameter in place of controller name in ASP MVC?

Retrieve Query String Parameter Value Containing URL in MVC Controller

how to pass parameter to show() method in resource controller from another function

How to pass extra parameter with JQuery Dropzone to my java controller method

How to pass JSON as parameter to Post method in controller .net api

How to get DropDownList SelectedValue in Controller in MVC

How to get DropDownList selected Text in MVC controller

How to prevent Url encoding when passing a parameter to method in MVC controller

How does Spring MVC controller method parameter work?

How to pass model between different method of controller from view MVC