chiapa
chiapa

Reputation: 4412

Send Dropdownlist select item to controller

I've got this in a View:

<form method="post" action="../MasterData/SaveRoad">
...
<input type="text" name="description" maxlength="100">
@Html.DropDownList("concessions")
...

And in a controller, this:

public ActionResult SaveRoad()
{
    string description = Request["description"].ToString();
    // code to get the dropdownlist selected value??
...

Now, I'm getting the description using the Request but how can I get the selected value of the dropdownlist?

Upvotes: 0

Views: 101

Answers (1)

Andrei
Andrei

Reputation: 56688

Doing Request["description"] is somewhat against the nature of ASP.NET MVC. Please don't. Rather declare this and the other input you have (dropdown) as parameters of the action:

public ActionResult SaveRoad(string description, string concessions)

Upvotes: 1

Related Questions