I'm writing an application in ASP.NET Core with Razor pages. I'm trying to display a data set in a set of tables with one table per person (SubmittedBy) and then table data that was submitted by that individual.
My Razor Page looks similar to the following (reduced for brevity).
@foreach (var user in Model.TableList)
{
<table class="table">
<thead>
<tr>
<th>@Html.DisplayNameFor(model => model.LoadTable.SubmittedBy): @Html.DisplayFor(modelItem => user.SubmittedBy)</th>
</tr>
<tr>
<th>@Html.DisplayNameFor(model => model.LoadTable.UID)</th>
...
...
...
</tr>
</thead>
<tbody>
@foreach (var item in Model.DataList)
{
<tr>
<th scope="row" class="text-center align-middle">
@Html.DisplayFor(modelItem => item.UID)
</th>
<td class="text-center align-middle">
@Html.DisplayFor(modelItem => item.Age)
</td>
...
...
...
</tr>
}
</tbody>
</table>
}
I'm using LINQ to create lists and populate the table as follows:
public IEnumerable<LoadTable> TableList;
public IEnumerable<LoadTable> DataList;
TableList = _context.LoadTable.Where(o => o.Approver == GetADDetails.displayName || o.Approver == GetADDetails.userName).GroupBy(user => user.SubmittedBy).Select(group => group.First()).ToList();
DataList = TableList.Where(p => TableList.Any(p2 => p2.SubmittedBy == p.SubmittedBy)).ToList();
Looking for an end result like the following:
I can't quite get the data the display correctly and there's something missing. Can anyone point me in the right direction?
Thanks,