I'm using ASP.NET MVC (1.0), Spark View Engine (1.0) and SubSonic (3.0.0.3).
I'm having some trouble getting an "Edit" view to work correctly. So, in my controller, I have the following controller action that displays the edit form view:
[AcceptVerbs(HttpVerbs.Get)]
public virtual ActionResult Edit(string name)
{
var plot = Plot.SingleOrDefault(p => p.UserID == LoggedInUser.ID && p.UrlFriendlyName == name);
// ViewData["plot"] = plot;
return View(plot);
}
The form on that view posts back to the following controller action:
[AcceptVerbs(HttpVerbs.Post)]
public virtual ActionResult Edit(Plot plot)
{
var validator = new PlotValidator();
try
{
var results = validator.Validate(plot);
if (!results.IsValid)
{
...
}
}
}
The problem that I'm having, is that the first controller action doesn't actually populate the form with the values from the Plot object submitted to it. The only way I can get it to populate the form is by adding the Plot to ViewData:
ViewData["plot"] = plot;
That populates the edit form, but when I edit the values, and submit it back to the second controller action listed above, it just sends back, basically a new plot with the new values, not the plot sent to the edit form with updated values.
I'm sure I'm probably just missing something simple, but I can't seem to figure out what it is. All of the fields on my form have IDs that are prefixed with "plot."
Anyone know/see what I'm doing wrong? Thanks.