I have an IList in my model. Which i am displaying as radio buttons. But when i submit the form the value is not correct and the model state is not valid and where the value for the selected radio button should be there is 'Count =0'
This the option in model:
[Display(Name = "My enquiry is regarding: *")]
public IList<Industry> A1_EnquiryRegarding { get; set; }
controller: populate list:
Industry blank = new Industry();
blank.Id = 0;
blank.Name = "Other";
IList<Industry> industryList = manager.GetIndustries();
industryList.Insert(industryList.Count, blank);
EnquiryModel.A1_EnquiryRegarding = industryList;
html:
<td>
<div class="editor-label">
<b> @Html.LabelFor(m => m.A1_EnquiryRegarding)</b>
</div>
<div class="editor-field">
@foreach (var radiobutton in Model.A1_EnquiryRegarding) {
@Html.RadioButtonFor(m => m.A1_EnquiryRegarding, radiobutton.Name)
<label>@radiobutton.Name</label>
<br></br>
}
@Html.ValidationMessageFor(m => m.A1_EnquiryRegarding)
</div>
</td>
where am i goign wrong? why am i not getting the correct selected value back?
Edit:
[HttpPost]
public ActionResult EnquiryForm(Enquiry Enquiry)
{