problem with dropdownlist in mvc application

Posted by czuroski on Stack Overflow See other posts from Stack Overflow or by czuroski
Published on 2010-04-13T14:13:16Z Indexed on 2010/04/13 14:23 UTC
Read the original article Hit count: 202

Filed under:

Hello, I am trying to work with an HTML.DropDownList in MVC and am not getting the expected return values. Here is my implementation for the selectList to bind to the drop down -

IEnumerable<status> stat = _provider.GetAllStatuses();
Statuses = new SelectList(stat.ToList(), "id", "name", i.status.id);

And here is my view -

<%= Html.DropDownList("Status",Model.Statuses) %>

I am getting an error when trying to run updatemodel in my controller. I then tried to individually set each object. It turns out that I am not getting a single int from the formvalue as I would expect to. Instead, I am getting a value like "5,10,2,3". I think this is coming from how I set up my selectlist, but I'm not exactly sure. Can anyone see an error in the way I am setting up this dd?

Thanks for any help, and let me know if I can clarify anything.

© Stack Overflow or respective owner

Related posts about asp.net-mvc