I ve a list which is filled by me and sorted! I wanna add some new items to that sorted list but these new items should be at the top of the list.
I’m adding items to list:
var OnlySup = dataContext.GroupDetails.Where(c => c.sup_id == c.suppliers.supplier_id).Select(c=>c.sup_id).Distinct().ToList();
/* GET SUPPLIERS FROM DB */
foreach (var supp in OnlySup)
{
/* ADD EACH SUPPLIER TO LIST */
SupplierList.Add(new SelectListItem() { Text = supp.supplier, Value = "S" + supp.supplier_id.ToString() });
}
Sorting:
/* ReOrder The List */
SupplierList = SupplierList.OrderBy(c => c.Text).ToList();
List items that i wanna add to the top of the list:
/* DEFAULT ADD */
SupplierList.Add(new SelectListItem() { Text = "ALL Groups", Value = "G" });
SupplierList.Add(new SelectListItem() { Text = "ALL Suppliers", Value = "S" });
SupplierList.Add(new SelectListItem() { Text = "ALL Suppliers AND Groups", Value = "%" });
/* GET GROUPS FROM DB */
var OnlyGroup = dataContext.groups.OrderBy(c => c.id).Distinct().ToList();
/* FOR EACH GROUP */
foreach (var groups in OnlyGroup)
{
/* ADD EACH GROUP TO LIST */
SupplierList.Add(new SelectListItem() { Text = groups.group_name, Value = "G" + groups.id.ToString() });
}
So how can i achive this?
why don’t you invoke the Insert method ?