I am trying to order my Html.List box based on a selected value from another Selected Dropdown but don't know how to do it
This is my Html.ListBox filled by a ViewBag o my VIEW
@Html.ListBox("Group", (IEnumerable<SelectListItem>)ViewBag.Group, new { style = "width: 300px;" })
This is my View Dropdown list:
<select id="sel2">
<option value="">Todos</option>
@foreach (var item in Model.Select(l => l.Rid).Distinct())
{
<option value="@item">@item</option>
}
</select>
And this is my ViewBag in the controller:
List<string> listadepuntos = new List<string>();
foreach (var item in db.Pos.Where(r => r.Fecha.Day <= today.Day)
.Select(g => new { Pdv = g.Pdv, Total = g.Total })
.GroupBy(l => l.Pdv).AsEnumerable().Select(z => new
{
Punto_De_Venta=z.Key,
Total = String.Format("{0:$#,##0.00;($#,##0.00);Zero}",Decimal.Round(z.Sum(l => l.Total), 0))
}))
{
listadepuntos.Add(item.ToString());
}
var grupoPdv = new SelectList(listadepuntos.ToList());
ViewBag.GroupS = grupoPdv;
Is there a way to order my Viewbag items from a Selected option in my dropdown? maybe using Javascript or something? i have no idea how to approach the problem