I am new to asp.net, MVC. I am trying to populate my dropdownlist. I found the following solution for this. How to write a simple Html.DropDownListFor ()? I am trying to find a BARAT solution for this, but is encountering a NullReferenceException error. Below is my code.
<%: Html.DropDownListFor(model => model.CreditCardType, new SelectList( new List<Object>{ new { value = 0, text="VISA"}, new { value = 1, text="Master"}, new { value = 2, text="Debit"}}, "value", "text", Model.CreditCardType) )%>
ErrorDetail: the reference to the object is not installed in the instance of the object.
Can anyone help me out? I could make a small mistake, but could not fix it.
source share