3
Man Controller:
public ActionResult AssociarDependencia(int codigoMilestone, int codigoAtividade)
{
try
{
using (CPMDatabaseEntities db = new CPMDatabaseEntities())
{
List<Atividade> lista = new List<Atividade>();
lista = db.Atividade.Where(a => a.CodigoMilestone == codigoMilestone).ToList();
ViewBag.Atividades = lista;
return View();
}
}
catch (Exception)
{
throw;
}
}
My View:
<div class="form-group">
@Html.Label("Atividade Sucessora", new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.DropDownList("Atividades")
</div>
</div>
</div>
Using the debug this runs normal, we see in the image below that the code returns 2 values.
But when the debug arrives in the @Html.DropDownList("Atividades")
he gives an exception as we see in the images below.
You want to return with some activity already selected?
– Randrade