We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to get the selected values in postback in DropdownlistFor control ?

Description

 

The DropDownList control supports strongly typed HTML helpers represented by lambda expressions that have model or template passed into the View.

 

Solution

 

You can get the selected values of  DropDownListFor control in postback by passing the parameter as a string array in code behind.

 

The following steps to explain how to get the selected item in post back.

  1. Create the model as shown below code:

 

C#

 

  1. Create an action method that renders UI on the view page, and passes the model to be bound to the view page.

C#

 

 

 

  1. Create a strong typed view based on your model.

CSHTML

  1. Get the selected item in code behind as shown below:

 

C#

 

                

 

You can get the selected values in the post action as follows:

Article ID: Published Date: Last Revised Date: Platform: Control:
7783 06/22/2017 06/22/2017 ASP.NET MVC DropDownList
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.