I want to display range from 2000 to 2020, so I am using this:
@Html.DropDownListFor(p => p.Year, Enumerable.Range(2000, 2020)
.Select(x => new SelectListItem { Text = x.ToString(),
Value = x.ToString() }));
But it is displaying Range from 2000 to 4019.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You need to pass count as second parameter here.
Learn more about Enumerable.Range
Enumerable.Range(2000, 21)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0