See below:
Edit.aspx View:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Test.Models.Friend>" %>
Edit
<h2>Edit</h2>
<% using (Html.BeginForm()) {%>
<%= Html.ValidationSummary(true) %>
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%= Html.LabelFor(model => model.Id) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Id) %>
<%= Html.ValidationMessageFor(model => model.Id) %>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.Name) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Name) %>
<%= Html.ValidationMessageFor(model => model.Name) %>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.Link) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Link) %>
<%= Html.ValidationMessageFor(model => model.Link) %>
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
<% } %>
<div>
<%= Html.ActionLink("Back to List", "Index") %>
</div>
Controller for the edit:
[Authorize(Roles = "Administrator")]
public ActionResult Edit(int id)
{
var eddy = friendsDB.Friends.Single(a => a.Id == id);
return View(eddy);
}
[HttpPost]
public ActionResult Edit(int id, string confirmButton)
{
var eddx = friendsDB.Friends.Single(a => a.Id == id);
try
{
UpdateModel(eddx, "Friend");
friendsDB.SubmitChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
DOES NOT UPDATE so its not a matter of refreshing view. It goes through the motion, and returns to "Index" which is supposed to happen, but the record remains unedited. Any ideas or alternatives to editing with linq to sql ? Thanks.