what is the best way make a dropdown list in MVC4 (View) that show current year plus next 10 years? Should I make an enum and then include it in my view model and make a variable of that enum type?
Enumerable.Range(DateTime.Now.Year, 10)
will give you numbers that you can then use in the SelectList() constructor for your DropDownList
When you use Enum for that it will hard coded .Every end of year you should have to re deploy the solution.So better to use as following code in your business layer and push into view layer then based on server Date every user can retrive the next 10 years.
IList<int> years= Enumerable.Range(DateTime.Now.Year, 10).ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With