I have a list of radiobuttons that I am generating from my model like this:
@foreach (var offer in Model.AvailableOffers)
{
<div>
@Html.RadioButtonFor(m => m.selectedAvailableOffer, offer)
@Html.Label(offer.begin_date.Month + "/" + offer.begin_date.Day + " - " + offer.end_date.Month + "/" + offer.end_date.Day + ", " + offer.offer_name)
</div>
}
Model includes these:
public List<AvailableOffer> AvailableOffers { get; set; }
public AvailableOffer selectedAvailableOffer { get; set; }
See how I am trying to post my offer
object back to my controller in the RadioButtonFor
method? This is obviously not working, but it's what I want to accomplish. Is there any way to post the whole selected offer
object back to my controller or am I stuck adding some sort of ID to my object and only posting back the ID as is suggested here:
Correct way to bind an mvc3 radiobutton to a model