0

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.

1 Answer 1

2

You need to pass count as second parameter here.

Learn more about Enumerable.Range

Enumerable.Range(2000, 21)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.