Darshan Unadkat
Darshan Unadkat

Reputation: 151

Asp .Net MVC Dropdown

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.

Upvotes: 0

Views: 32

Answers (1)

Amit Kumar
Amit Kumar

Reputation: 5962

You need to pass count as second parameter here.

Learn more about Enumerable.Range

Enumerable.Range(2000, 21)

Upvotes: 2

Related Questions