My Cart viewmodel is
public class CartViewModel
{
public List<PaymentMethods> PaymentMethod { get; set; }
}
My PaymentMethods class
public partial class PaymentMethods
{
public int PaymentMethodID { get; set; }
public string PaymentName { get; set; }
public bool Active { get; set; }
}
My view is
@foreach (PaymentMethods pm in Model.PaymentMethod)
{
if (pm.Active)
{
<li>
@Html.RadioButtonFor(c => c.PaymentMethod, pm.PaymentMethodID, new { id = "pay" + pm.PaymentMethodID, @class = "paymethod" })
<label for="@("pay" + pm.PaymentMethodID)" class="checkbox">@pm.PaymentName</label>
</li>
}
}
And the controller accepts the CartViewModel as parameter.
[HttpPost]
public ActionResult Index(CartViewModel CartViewModel)
{
}
The question is why when i choose a Payment method and submit the form, the controller has PaymentMethod.Count equal to zero?
The selection is not passed on the controller. What am i doing wrong here?