Nickson
Nickson

Reputation: 135

C# MVC Not able to save item list from Dropdown

I have a custom <select> HTML statement with items. Unfortunately, upon submitting the form, the data is not pushed to the database but rather rendered as NULL.

Partial Code segment is as below:

<select name="RootCause" id="RootCause" class="form-control">

@if (Model.RequestType == "Membership" || Model.RequestType == "Membership/Registration" || Model.RequestType == "General Enquiries")
{
<option value="Collaboration tool error">Collaboration tool error</option>
<option value="Syntax system error">Syntax system error</option>
}

The field RootCause is where the values should be populated into.

Any assistance would be appreciated.

Upvotes: 0

Views: 37

Answers (1)

Amit
Amit

Reputation: 823

[HttpPost]
public ActionResult ActionName(FormCollection form)
{           
  string RootCause = form["RootCause"];
  return View();
}

By using FormCollection we can easily captured the value of RootCause field.

Upvotes: 1

Related Questions