I have an enum like this:
public enum PaymentType
{
Self=1,
Insurer=2,
PrivateCompany=3
}
And I am showing it as select box options like this inside Controller:
List<Patient.PaymentType> paymentTypeList =
Enum.GetValues(typeof (Patient.PaymentType)).Cast<Patient.PaymentType>().ToList();
ViewBag.PaymentType = new SelectList(paymentTypeList);
Here I can see that only the string part (example "Self") of the enum is going to the front end, so I won't get the value (example "1") of enum in my dropdown. How can I pass text as well as value of enum to select list?
DefaultModelBinderwill bind to the string value when you post back, but these answers show some methods to do it.intit will give you theintvalue.