1
In my layout I have an option where I show some notifications, to include in the layout a partial :
@Html.Partial("_PartialNotificacoes")
@model IEnumerable<Generico.Dominio.TB_NOTIFICACAO>
@if (Model.Count() > 0)
{
foreach (var item in Model)
{
<a href="Home/LerNotificacao/@item.IDNOTIFICACAO">
<!--lista de notificações-->
<i class="fa fa-users text-aqua"></i> @Html.DisplayFor(c => item.DESCRICAO);
</a>
}
}
The problem occurs when and called a new listing page because it will also have its own Ienumerable, Example page call:
public ActionResult ListarValorAssinatura()
{
var tbuscar = new ValorAssinaturaAplicacao();
var listar = tbuscar.ListarTodos();
var tbuscarNotificacao = new NotificacaoApliacao();
var retorno = tbuscarNotificacao.ListarTodos();
if (retorno != null)
{
ViewData["QtdNotificacao"] = retorno.Count();
// ViewData["ListaNotificacao"] = retorno;
}
return View(listar);
}
At this point I’m returning to the list, but I’m not returning notifications, so I have an error:
An Exception of type 'System.Invalidoperationexception' occurred in System.Web.Mvc.dll but was not handled in user code Additional information: The model item passed into the Dictionary is of type 'System.Collections.Generic.List
1[Generico.Dominio.TB_VALOR_ASSINATURA]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1[Generic.Dominio.TB_NOTIFICACAO]'.
Options I’ve tried before:
@Html.Partial("_PartialNotificacoes")
@Html.Partial("~/BuscarNotificacoes/Home/_PartialNotificacoes.cshtml")
@Html.Action("BuscarNotificacoes", "Home").
you want to resume two list one would be the page that loads and inside it a partialView also loads the other list?
– novic
@Virgilionovic, yes,
– Harry