Skip to content

Instantly share code, notes, and snippets.

@vquaiato
Created February 22, 2011 21:14
Show Gist options
  • Select an option

  • Save vquaiato/839406 to your computer and use it in GitHub Desktop.

Select an option

Save vquaiato/839406 to your computer and use it in GitHub Desktop.
View acessando uma collection para criar um dorpdown
@model MvcApplication5.Models.Manolo
@using System.Linq;
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
<div>
@Html.DropDownListFor(model => model.Nome,
((IEnumerable<MvcApplication5.Models.Manolo>)ViewBag.Manolos).Select(o => new SelectListItem
{
Selected = o.Nome == Model.Nome,
Text = o.Nome,
Value = o.Nome
}))
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment