One little thing before the example: in another post I got the solution. Simple use ViewData.Eval("MyField") to get the desired behaviour. Now for the example...
Here's a brief example using only 1 field. As for the view:
<%= Html.TextArea("MyText", ViewData["MyText"]) %>
In the controller,the actionmethod that is used to create a new record:
public ActionResult CreateNew()
{
return View("MyEditView");
}
the method for updating an existing record:
public ActionResult EditExisting(String id)
{
//loop through tempdata and assign any values from it to viewdata equivalents, so if we come here by an error in the SaveData method, we still have the user input
//get the item from LINQ to SQL using the specified ID
ViewData.Model = retreiveditem;
return View("MyEditView");
//note: in the perfect scenario, the view will render everything from ViewData.Model except for data present in ViewData dictionary, so user input (if we come from a SaveData error) takes priority on database data
}
and the actionmethod called with POST:
public ActionResult SaveData(String MyText)
{
//try to save the data, if ok return success view
//in case of error or invalid user input, memorize MyText in TempData["MyText"] and redirect to EditExisting method
}
This example should make it all clear. As stated above, the use of ViewData.Eval("varname") solves it, so I think further debate is pointless.