Your model properties Gender
and Disablity
would conflicts when submit form post.
MVC try to convert radio inputs selected values (which is of type string[]
) to your ViewModel property type IList<SelectListItem> Gender
rename the selected values or add new properties
Model properties
public IList<SelectListItem> Gender { get; set; }
public IList<SelectListItem> Disablity { get; set; }
public string[] SelectedGender { get; set; }
public string[] SelectedDisablity { get; set; }
View
rename your input to "SelectedGender" and "SelectedDisablity"
@foreach (var names1 in @ViewBag.Gender)
{
var tdId = "rd" + names1.Value;
<input type="radio" class="chkclass" value="@names1.Text" name="SelectedGender" />
@names1.Text
}
Action
also in action parameters
public ActionResult HandleFormSubmit(string[] selectedGender, string[] selectedDisability, FormViewModel model){ //...