0
I have an error in passing the contents of the controller to the view, I am doing so, Viewbag is being filled with the data.
In my application I select the items:
public List<TB_EMPRESA> ListarTodos()
{
var strQuery = "select * from tb_empresa";
using (contexto = new Contexto())
{
var retornoDataReader = contexto.ExecutaComandoComRetorno(strQuery);
return TransformaReaderEmListaObjetos(retornoDataReader);
}
}
in the controller:
// GET: CadastroUsuario
public ActionResult Index()
{
//lista empresa
var tbuscarEmpresa = new EmpresaAplicacao();
var listarEmpresa = tbuscarEmpresa.ListarTodos();
ViewBag.Empresa = listarEmpresa;
return View();
}
in View
<div class="col-md-3 form-group">
@Html.LabelFor(x => x.tbidempresa)
@Html.DropDownListFor(x => x.tbidempresa.IDEMPRESA, ViewBag.Empresa as SelectList, "Selecione um item..", new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.tbidempresa)
</div>