Once you are POST-ing back to your View, you will need to manipulate the values in your ModelState (not your Model) using the SetModelValue() method. Alternatively, you could Remove()
the offending entry, but that has other implications (i.e., damaging your model in the ModelStateDictionary object).
For example if your data element was called RequiredDateTime
, then your controller code might be:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ThisAction(int id, YourModel model)
{
// Process the 'IsValid == true' condition
if (ModelState.IsValid)
{
// ...
return RedirectToAction("NextAction");
}
// Process the 'IsValid == false' condition
if (ModelState.ContainsKey("RequiredDateTime"))
{
ModelState.SetModelValue("RequiredDateTime", new ValueProviderResult(...));
}
// ...
return View(model);
}
EDIT
A little additional research turned up the following, see also:
MVC - How to change the value of a textbox in a post?
How to modify posted form data within controller action before sending to view?
I hope this helps. Good luck!