I'm having this issue where I'm unable to update a data. It will go to the edit page but when I click update it just redirects to the other page and there's no data shown. How can get the updated data to be shown when it is redirected. Update question with class issue
controller:
private Issue getIssue
{
get
{
Issue issue = (Issue)Session["Issue"];
if (issue == null)
{
issue = new Issue();
Session["Issue"] = issue;
}
return issue;
}
}
public ActionResult Edit(int id)
{
getIssue.item = getIssue.items[id - 1];//Returns the requested item for editing
return View(getIssue);
}
[HttpPost]
public ActionResult Edit(Issue issue)
{
int indx = issue.item.lineNum - 1;
getIssue.items[indx] = issue.item;
//return View(getIssue);
return RedirectToAction("IssueItem", "Issue");
}
View:
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Issue</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<fieldset>
<div class="form-horizontal">
<hr />
<div class="form-group">
<div class="form-group">
@Html.LabelFor(model => model.item.itemNumber, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.TextBoxFor(model => model.item.itemNumber, null, new { @id = "itemNumber", @class = "form-control", @readonly = "readonly", })
@Html.ValidationMessageFor(model => model.item.itemNumber, "", new { @class = "text-danger" })
</div>
<div class="form-group">
@Html.LabelFor(model => model.item.description, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.TextBoxFor(model => model.item.description, null, new { @id = "description", @class = "form-control", @readonly = "readonly", })
@* @Html.EditorFor(model => model.item.description, new { @class = "control-label col-md-2", @id = "txtItem" })*@
@Html.ValidationMessageFor(model => model.item.description, "", new { @class = "text-danger" })
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Update" name="Update" class="btn btn-default" />
<input type="button" value="Cancel" name="Cancel" onclick="location.href='@Url.Action("IssueItem","Issue")' " class="btn btn-default" />
</div>
</div>