0

I have this view that is a menu page:

@model SGP.Models.Turma

<h2>MENU</h2>
@Html.ActionLink("Ver Notas das Componentes", "AvaliacaoLista", "Turma", new { id = Model.TurmaId }, null)
@Html.ActionLink("Ver Notas das SubComponentes", "ListaSubs", "Componente", new { id = Model.TurmaId }, null)
@Html.ActionLink("Ver Nota Final", "CalcularNotaFinal", "Turma", new { id = Model.TurmaId }, null)

But i would like to show in this same page a table from another model:

@model  List<SGP.Models.PessoaModel2>

    <table>
        <tr>
            <th>Nome</th>
            <th>Numero</th>
            @foreach (String s in ViewBag.Componentes)
            {
                <th>@s</th>
            }
            <th>Nota Final</th>
        </tr>
        @for (int i = 0; i < Model.Count; i++)
        {
            <tr>
                @Html.HiddenFor(x => Model[i].turmaId)
                @Html.HiddenFor(x => Model[i].userid)
                <td>@Model[i].nome</td>
                <td>@Model[i].num</td>

                @for (int a = 0; a < Model[i].am.Count; a++)
                {
                    @Html.HiddenFor(x => Model[i].am[a].AvaliacaoId)
                    <td>@Html.DisplayFor(x => Model[i].am[a].nota)</td>
                }           
            </tr>
        }
    </table>
}

Is it possible? The objective is to show this table from PessoaModel2 Model in the menu page from Turma Model. Other way i thought was to turn the menu page into List SGP.Models.PessoaModel2 to put the table but then the links wouldn't work. Can someone help me? Thanks

dasdasd
  • 97
  • 1
  • 14
  • There are multiple ways. - e.g. create a view model containing all the properties you need, use `@Html.Action()` to call a server method that return the 2nd view. –  Nov 27 '16 at 21:54

2 Answers2

0

You can include a Partial View in another view (or partial) with using the Html.Partial. Here is another good resource in this topic, beware of the differences between the techniques mentioned in that post..

Community
  • 1
  • 1
Zoltán Tamási
  • 12,249
  • 8
  • 65
  • 93
0

You may user Tuple class to join to models

Yazan Ati
  • 351
  • 1
  • 2