ASP.NET MVC 2 Html.TextAreaFor not updating on Edit -
i have form lets user enter in text. longer few characters want use textarea instead of textbox.
the html.textboxfor works without issue, , html.textareafor works when create entry, not store new value when edit , shows whatever value before went edit upon saving.
on page:
<div> <label>work performed:</label> <%: html.textareafor(model => model.workperformed)%> <%: html.validationmessagefor(model => model.workperformed) %> </div>
code behind create:
maintperformed.maintdate = datetime.parse(request.form["maintdate"]); maintperformed.workperformed = request.form["workperformed"]; maintperformedrepository.add(maintperformed); maintperformedrepository.save(); return redirecttoaction("details", new { id = maintperformed.id });
code behind edit:
maintperformed.maintdate = datetime.parse(request.form["maintdate"]); maintperformed.workperformed = request.form["workperformed"]; maintperformedrepository.save(); return redirecttoaction("details", new { id = maintperformed.id });
what missing on edit side of things?
in both cases redirecting details
action. make sure maintperformedrepository.save()
, importantly in details
action value fetched data store. suspect either database not updated or in details
action fetching wrong value model.
remark: instead of writing ugly datetime.parse(request.form["maintdate"]);
, request.form["workperformed"];
pass view model argument controller action , let model binder populate request values.
Comments
Post a Comment