I have been trying to loop through a list inside of a drop down list but it doesn't seem to be working. Here's the code.
public class AnimalHandler
{
public List<string> DogBreeds = new List<string>()
{
"Affenpinscher","Lhasa Apso","Shitzu", "Tibetan Terrier"
}
}
And then in the view
Project1.Models.AnimalHandler animal = new Project1.Models.AnimalHandler();
@Html.DropDownList("breed", new List<SelectListItem> {
foreach(var item in animal.DogBreeds)
{
new SelectListItem {Text="item", Value=""},
}
new SelectListItem {Text="Choose a Breed", Value=""}
})
My thought behind it would be that var item would loop through all the items in the DogBreeds however there seems to be an error and I can't figure out what it could be.
Perhaps there is another SIMPLE way of doing this? Thanks