i'm trying to get the Id of a DropdownList into a model using Enum but I always get null inside the variable of the Model. Hier ist my Code.
Model:
public partial class Vehicule
{
public int vehiculeID { get; set; }
public Nullable<int> paidTextID { get; set; }
}
the Enum Class
public class EnumClass
{
public enum Paid
{
Yes = 1 ,
No = 2 ,
NotComplete= 3,
}
}
and the View
<div class="form-group">
@Html.LabelFor(model => model.paid, new { @class = "control-label col-md-2" })*
<div class="col-md-10">
@Html.DropDownListFor(model => model.paidTextID, Enum.GetValues(typeof(EnumClass.Paid)).Cast<EnumClass.Paid>().Select(x => new SelectListItem { Text = x.ToString(), Value = ((int)x).ToString() }), new { style = "width: 500px" })
@Html.ValidationMessageFor(model => model.paid)
</div>
</div>
The List is populated but when I select I till have null inside the paidTextID.
Please Help
Thx