I have a List<SelectListItem>
that I build from a List that contains videos so I can create a dropdown in the view but I only want to select the unique values, I have tried to select distinct:
List<SelectListItem> items = new List<SelectListItem>();
foreach (var video in VidModel)
{
items.Add(new SelectListItem() { Text = video.Name, Value = video.showName, Selected = false });
}
ViewBag.showName = items.Distinct();
But this returns all the values