Hi this is more of an MVC question. I am implementing a save functionality in my MVC application. I have written a HTTPPOST method to save the records. When I am trying to pass the viewmodel to the view , I am amending one of the properties called requestID. This requestid is retrieved after i save a request. When my view loads I dont see the requestid field containing the data. I have bound the control correctly. Do you loose the viewmodel information during the post operation. What I am looking at is I need to refresh my view with the latest request that I have saved.
[HttpPost]
public ActionResult Request_Insert(NewRequestViewModel newRequestViewModel)
{
newRequestViewModel.CompanyCode = "8100";
newRequestViewModel.RequestStatusCode = "New";
if (!ModelState.IsValid)
{
return null;
}
int requestId = requestRepository.CreateRequest(Mapper.Map<Request>(newRequestViewModel));
newRequestViewModel.RequestID = requestId;
return View("NewRequestView", Mapper.Map<NewRequestViewModel>(newRequestViewModel));
}
Requestid field
@model CC.GRP.MCRequest.ViewModels.NewRequestViewModel
<div class="form-group">
@Html.LabelFor(model => model.RequestID, htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
<div class="editor-field">
@Html.EditorFor(model => model.RequestID, new { htmlAttributes = new { @class = "form-control", style = "width:100%", @readonly = "readonly" } })
</div>
@Html.ValidationMessageFor(model => model.RequestID, "", new { @class = "text-danger" })
</div>
</div>