Reputation: 15297
My ViewModel is as follows:
public class ClassificationCalculatorIndexViewModel
{
public bool PlacementYear { get; set; }
public int[] Credit { get; set; } // List of Integers
public int selectedCredit { get; set; } // Somewhere to store selected integer
public List<YearOfStudy> StudyYear { get; set; }
}
I am struggling to bind the Integer array to a DropDownList helper object in my Razor view, I am doing the following:
@Html.DropDownListFor(Model.selectedCredit, Model.Credit)
But getting errors, I tried Googling, but found nothing of the same nature :(
Upvotes: 0
Views: 4233
Reputation: 236268
I think you need drop down for selectedCredit
filled with items from Credit
property:
@Html.DropDownListFor(m => m.selectedCredit, new SelectList(Model.Credit))
Upvotes: 4
Reputation: 14133
You need to create a SelectList
object with the content of your int[]
.
Upvotes: 0