0

I'm using the helper Html.DropDownList in an MVC 3 solution. I have it working to the point where I can select a menu item, post it to the controller, update the db, set my model's item selected to the actual item selected and return the model to the view:

 <td colspan="3">
                <%=Html.DropDownList("Id", Utilities.menuItems(), "-Select One-") %>
            </td>

So, in this example, I populate the drop down with an external static method (Utilities.menuItems()) and set the default label to be 'Select One'.

On the second pass, how do I set the drop down to defualt to the value I selected?

user2284341
  • 661
  • 4
  • 17
  • 38
  • 2
    have a look here: http://stackoverflow.com/questions/624828/asp-net-mvc-html-dropdownlist-selectedvalue – Black.Jack Nov 22 '13 at 18:09
  • I already did. No reply has been marked as an answer and the part marked 'UPDATE' doesn't fully address my issue. I've written a model that has a property of the id set to 1-5 that corresponds to the item selected. The questioner you recommended doesn't do this. – user2284341 Nov 22 '13 at 18:35
  • 1
    _"No reply has been marked as an answer"_ - that doesn't mean none of them work. Check the ones with the most upvotes, they do explain how you can do this using `SelectList`. – CodeCaster Nov 22 '13 at 18:44
  • No, but it doesn't mean they do work either. I'm not going to waste my time trying a different way just because a number of other coders agree. Usually I've asked a question here and someone responds, after a reasonable amount of time, with an answer. I'm not expecting someone to climb inside my head and know exactly what my problem is and come up with the exact solution. But if the answer seems to be, and I'm paraphrasing here, 'use a SelectList' then I may as well have just googled it and not bother with SO at all. – user2284341 Nov 22 '13 at 18:59
  • There are millions of questions about this on SO. – ataravati Nov 22 '13 at 20:19
  • "then I may as well have just googled it and not bother with SO at all." Um... precisely? – Robin Green Nov 22 '13 at 21:12
  • Yes, I thought I might provoke a lot of snotty comments and neither ataravati or Robin Green would disappoint. – user2284341 Nov 22 '13 at 22:12

0 Answers0