I haven't worked with radio buttons much and I'm new to MVC.
I'm trying to get the value of selected radio button from the view to the controller Post method. All other element values are coming expect the radio button. They always return false
Here is my code
VIEW
<label for="first" class="col-sm-3 control-label">Patient Name:</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="first" placeholder="First" name="FirstName">
</div>
<div class="col-sm-2">
<input type="text" class="form-control" id="middle" placeholder="Middle" name="MiddleName">
</div>
<div class="col-sm-3">
<input type="text" class="form-control" id="last" placeholder="Last" name="LastName">
</div>
<div class="col-sm-1"></div>
</div>
<div class="form-group">
<label for="month" class="col-sm-3 control-label">DOB:</label>
<div class="col-sm-2">
@Html.DropDownList("MonthofBirth", Acc.Web_Code.viewmodels.Calendar.MonthsSelectList, "Month", new { @class = "form-control", name = "month", id = "month" })
</div>
<div class="col-sm-1">
@Html.DropDownList("DayofBirth", Acc.Web_Code.viewmodels.Calendar.DaysSelectList, "Day", new { @class = "form-control", name = "day", id = "day" })
</div>
<label class="radio-inline">
<input type="radio" name="Gender" id="male" value="Male"> Male
</label>
<label class="radio-inline">
<input type="radio" name="Gender" id="female" value="Female"> Female
</label>
Post Method
public ActionResult AddNewPatient(AddPView objAddPView)
and my model is
public class AddPView
{
[Required]
public string FirstName { get; set; }
public string MiddleName { get; set; }
[Required]
public string LastName { get; set; }
public bool Gender { get; set; }
[Required]
public string YearofBirth { get; set; }
[Required]
public string MonthofBirth { get; set; }
[Required]
public string DayofBirth { get; set; }
[Required]
public string Address1 { get; set; }
[Required]
public string City { get; set; }
[Required]
public string State { get; set; }
public string Zip { get; set; }
[Required]
public string Phone { get; set; }
}
Tried a lot of variation in view but every thing returns false