'pass the selected value of Html.DropDownList to controller
I have a drop down in my view page. Since the drop down has only two values and it will not change so we decided to create static drop down.
@Html.DropDownList("RelationshipWithFather", new List<SelectListItem>()
{
new SelectListItem() { Text= "son", Value = "son" },
new SelectListItem() { Text= "daughter", Value = "daughter" }
}, "relationship...", new { @class = "form-control" })
How to pass the selected value of this RelationshipWithFather drop down to create controller method.
public ActionResult Create(PatientInfo vdm_)
{
if (ModelState.IsValid)
{
PatientInfo vdm = new PatientInfo();
vdm.relationshipWithPatient = // selected value of RelationshipWithFather
}
}
I have to set the value of the selected dropdown to the relationshipWithPatient attribute of the model class.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
