绑定DropDownListFor

ViewModel

1  public class ArticleViewModel

2     {

3         public IEnumerable<SelectListItem> selectList { get; set;}      

4     }

Controlles

public ActionResult Add()

        {

            ArticleViewModel viewModel = new ArticleViewModel();

            IList<ArticleTypeInfo> l = ServiceFactory.ArticleTypeService.GetAll();

            viewModel.selectList = l.Select(a => new SelectListItem

            {

                Text = a.ArticleTypeName,

                Value = a.ArticleTypeId.ToString()

            });

            return View(viewModel);

        }

View

@Html.DropDownListFor(m => m.ArticleTypeId, Model.selectList,"请选择")

你可能感兴趣的:(list)