Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

Need a demo MVC app that fills a drop down list in the View

I have used Nerd Dinner as an example but can not get that one to work for me.  Does anyone have a demo I can download that uses HTML.DropDownListFor to populate a list?  I am having problems doing that successfully.

Thanks,
newbieweb
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

I agree about ViewData. I attempted going direct to my Model, with no success.  They behaved the same.  I agree that Strong Typing is the only way to go.

Now on to the Music Store...
Question.

Do I need to add each item in the aspx file? Or shoudl the following be sufficient?
Html.DropDownListFor(model => model.role, ViewData["RoleList"] as SelectList)

Maybe I misunderstood Nerd Dinner. I see Musis Store has the attached code. But I have not looked at it very long to try and figure it out myself....
    <% foreach (var genre in Model) { %>
    <li>
        <%: Html.ActionLink(genre.Name, "Browse", "Store", new { Genre = genre.Name }, null)%>
    </li>
    <% } %>

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. For the record, I had not yet overrridden ToString(), which I think is why I got the list filling with MyProgram.Models.User.