0

I've got a problem with getting out the selected value in my DropDownList. In my ViewModel I created a list

public SelectList movies;

and populated it in GET method with the following values

foreach (Movies m in db.Movies)
{
     movies.Add(new SelectListItem { Text = m.Title, Value = m.IdMovies.ToString() });
}

And displayed it like:

@Html.DropDownListFor(m => m.IdMovies, Model.movies, "--Select Movie--")`

How can I get the selected value in my POST method?

tereško
  • 57,247
  • 24
  • 95
  • 149
MemoryLeak
  • 59
  • 5
  • Please describe your POST method in controller and what data you send? – Maxim Goncharuk Dec 07 '15 at 14:55
  • 2
    As soon as you selects a text the associated value automatically gets assigned to `IdMovies` property. Make sure the form method is post and the whole model is passed on to controller as arguement, Thats it. – Suprabhat Biswal Dec 07 '15 at 14:58

0 Answers0