Best way of implementing DropDownList in ASP.NET MVC 2?

后端 未结 5 2071
小蘑菇
小蘑菇 2020-12-09 19:40

I am trying to understand the best way of implementing a DropDownList in ASP.NET MVC 2 using the DropDownListFor helper. This is a multi-part ques

5条回答
  •  借酒劲吻你
    2020-12-09 20:04

    Your best bet is to create a SelectList in your Controller - use my extension method here: http://blog.wekeroad.com/2010/01/20/my-favorite-helpers-for-aspnet-mvc

    Pop that into ViewData using the same key as your property name: ViewData["statusid"]=MySelectList

    Then just use Html.DropDownFor(x=>x.StatusID) and you're all set.

提交回复
热议问题