コード例 #1
0
        private List <SelectListItem> GetDriverForDropDownList()
        {
            var drivers = aTransportManager.GetAllDrivers();

            List <SelectListItem> items = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "", Text = "--Select--"
                }
            };

            foreach (Driver driver in drivers)
            {
                SelectListItem item = new SelectListItem()
                {
                    Value = driver.Id.ToString(), Text = driver.Name
                };
                items.Add(item);
            }

            return(items);
        }