I have a ViewBag in my controller witch contains a List of Linq Items, I created a Foreach Loop in my View to create a table based on the Data in the Viwbag but i get "System.Web.Mvc.SelectListItem" for each item in my loop
Controller Viewbag Code:
foreach (var item in db.Pos.GroupBy(a => a.Pla).Select(p => new
{
Pla = p.Key,
Pdv = p.Select(a => a.Pdv).FirstOrDefault(),
Nombre = p.Select(a => a.Descripcion).FirstOrDefault(),
Rid = p.Select(a => a.Rid).FirstOrDefault(),
Quantity = p.Sum(q => q.Cantidad),
Total = p.Sum(x => x.Total),
Fecha = p.Select(a => a.Fecha).FirstOrDefault()
}))
{
listapop.Add(item.Pdv);
listapop.Add(item.Pla);
listapop.Add(item.Nombre);
listapop.Add(item.Rid);
listapop.Add(item.Quantity.ToString());
listapop.Add(item.Total.ToString());
listapop.Add(item.Fecha.ToString());
}
var grupopopularidad = new SelectList(listapop.ToList());
ViewBag.GroupPops = grupopopularidad;
And mi View Table :
<table>
<thead>
<tr>
<th>Punto de Venta</th>
<th>Platillo</th>
<th>Nombre</th>
<th>Turno</th>
<th>Cantidad</th>
<th>Ingresos</th>
<th>Fecha</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.GroupPops)
{
<tr>
<th>@item</th>
</tr>
}
</tbody>
</table>