Q:

Mass edit ISingleResult

I got a stored procedure which i show in the view for edits. I made a strong type of the stored procedure. When i edit the fields and then press the save button, the parameter "cm" is always empty. And it's not showing a list but just 1 record.
The custom model:
public class CustomModel
    {
        public string Description { get; set; }
        public System.Data.Linq.ISingleResult<GetItems_ListResult> ItemList { get; set;}
    }

This part of the controller sends it to the view:
 public ActionResult Details(int id)
 {
    var row = dataContext.Items.FirstOrDefault(x => x.ItemID == id);
    var cm = new CustomModel();
    cm.ItemList = dataContext.GetItem_List(row);
    cm.Description = row.Description;

    return View(cm);
 }

This controller receives data from the view:
[HttpPost]
public ActionResult UpdateItems(CustomModel cm)
{

   return RedirectToAction("Index");
}

This is the view:
@model TestWeb.Models.CustomModel

@using (Html.BeginForm("UpdateItems", "Item", FormMethod.Post))
{

     <table>
            <tr>
                <th>Name</th>
                <th>Description</th>
            </tr>
        @foreach (var p in Model.ItemList.ToList())
        {
            <tr>
                <td>
                    @Html.HiddenFor(mdl => p.ItemId)
                </td>
                <td>@p.Name</td>
                <td>
                    @Html.EditorFor(mdl => p.Description)
                </td>
            </tr>
        }
    </table>

    <p>
        <input type="submit" value="save" />
    </p>
}

What am i doing wrong here?

A:

Try the following:
Make a GetItems_ListResult.cshtml like this:
<tr>
 <td>
    @Html.HiddenFor(mdl => mdl.ItemId)
 </td>
  <td>@Model.Name</td>
 <td>
    @Html.EditorFor(mdl => mdl.Description)
 </td>
</tr>

Then in your for loop do this:
@for (int i = 0; i < Model.ItemList.Count(); i++)
{
   @Html.EditorFor(m => m.ItemsList[i])
}

Update: I didn't quite notice you were using an ISingleResult. You could do this instead:
//Since it'll have none or one element..
if(Model.ItemList != null  && Model.ItemList.Any())
{
  @Html.EditorFor(m => m.ItemList.First())
}

