HTML.DropDownListFor - Syntactic Sugar for SelectList?

Use Enumerable. Range to generate the range of numbers.

Up vote 2 down vote favorite share g+ share fb share tw.

I am using Html. DropDownListFor to build a select list. It is a simple list of numbers from 1 to 100.

One of the parameters - selectList As System.Collections.Generic. IEnumerable(Of SelectListItem) - is the list's options, which I have usually built manually, like this: @Html. DropDownListFor(Function(x) x.Sorting.

IsAscending, _ New SelectList(New Dictionary(Of String, Boolean) From _ {{"Sort Ascending", True}, {"Sort Descending", False}}, "value", "key")) Or from an enum, like this: @Html. DropDownListFor(Function(x) x.Sorting. SortFieldCurrent, _ New SelectList(Model.Sorting.

SortFields, "value", "key")) But this time I want a list from 1 to 100. And I refuse to manually create it :) Is there some sweet LINQ magic to build a list for me? Vb.net linq asp.

Net-mvc-3 razor link|improve this question edited Jan 27 at 22:10Kyle Trauberman8,81121648 asked Jan 27 at 21:55Shai Cohen3689 83% accept rate.

Use Enumerable. Range to generate the range of numbers: C#: IEnumerable range = Enumerable. Range(1, 100); VB (Courtesy developerfusion.com/tools/convert/csharp...): Dim range As IEnumerable(Of Integer) = Enumerable.

Range(1, 100) http://msdn.microsoft.com/en-us/library/system.linq.enumerable.range.aspx.

Perfect thanks! Extra point for the vb version :) – Shai Cohen Jan 27 at 22:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions