I have a view with a drop down, which is tied to the view model…
One of the view model’s properties:
public int selectDTypeID { get; set; }
the view has a drop down:
Html.DropDownListFor(
model => model.selectDTypeID ,
new SelectList(
new List<Object>{
new { value = 1 , text = "Test1" },
new { value = 2 , text = "Test2" },
new { value = 3 , text = "Test3"}
},
"value",
"text"
)
)
How can I get the the value of the drop down list on post back without using an extra parameter… I’d just like to be able to do this…
[HttpPost]
public ActionResult ContinueDonation(AddDonationViewModel model)
{
var id = model.selectDTypeID;
}
Can I do something like this?
If your View is a strongly typed view like this,
When you click on submit, the selected value will be available in the SelectdTYpeID property in your HttpPost Action method