0

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.

2
  • Try to remove if for the test or wrap with if the whole select, not just a part Commented Feb 15, 2022 at 13:08
  • 1
    Can you show the relevant parts of your view-model? In particular, is the RootCause a writeable string property on the root view-model? Commented Feb 15, 2022 at 13:28

1 Answer 1

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

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.