1
Is giving the error below in dropdowList and do not understand why.
Error:
Cannot associate the 'System.Collections.Generic.List1[<>f__AnonymousType82[System.Int32,System. Stri ng]]' to type 'System.Web.Mvc.Selectlist Controller:
public ActionResult CriarInscricao()
{
var queryNomeCatequizando = ( from c in db.Catequizando
join p in db.Pessoa on c.CatequizandoID equals p.PessoaID
where c.CatequizandoID == p.PessoaID
select new { PessoaID = p.PessoaID, Nome = p.Nome});
ViewBag.Catequizando = queryNomeCatequizando.ToList();
return View();
}
View:
@Html.DropDownListFor(model => model.CatequizandoID, (SelectList)ViewBag.Catequizando, htmlAttributes: new { @class = "form-control" })
What a mistake you’re making?
– Jéf Bueno
"Cannot associate 'System.Collections.Generic.List type object
1[<>f__AnonymousType8
2[System.Int32,System. String]]' to type 'System.Web.Mvc.Selectlist'."– Simão Lopes