Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save vquaiato/839404 to your computer and use it in GitHub Desktop.
Controller usanod collection para criar dopdown na view
using System.Collections.Generic;
using System.Web.Mvc;
using MvcApplication5.Models;
namespace MvcApplication5.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
var manolos = new List<Manolo>
{
new Manolo {Nome = "Manolo 1"},
new Manolo {Nome = "Manolo 2"},
new Manolo {Nome = "Manolo 3"},
new Manolo {Nome = "Manolo 4"},
new Manolo {Nome = "Manolo 5"},
};
ViewBag.Manolos = manolos;
return View(new Manolo { Nome = "Manolo 3" });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment