I am new to asp.net, MVC. I am trying to populate my dropdownlist. I found following solution for that. How to write a simple Html.DropDownListFor()? I am trying BARAT's solution for that but facing error of NullReferenceException. Following 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: Object reference not set to an instance of an object.
Can Anyone please help me? I might be making small mistake but not able to fix it.