ModelState.AddModelError wird in meiner Ansicht nicht angezeigt

Ich habe die folgende Ansicht, die 10 Ajax.beginform erstellen, aber das Problem, das ich bin, ist, dass ein Fehler bei der Erstellung des Objekts auftritt, dann wird der ModelState.AddModelError in der Ansicht nicht angezeigt, obwohl ich festgelegt habe das@Html.ValidationSummary(true) Die Ansicht sieht wie folgt aus

<code>@model Medical.Models.VisitLabResult

@for (int item = 0; item < 10; item++)
{
    <tr id = @item>
    @using (Ajax.BeginForm("CreateAll", "VisitLabResult", new AjaxOptions
    {
        HttpMethod = "Post",
        UpdateTargetId = item.ToString() + "td",
        InsertionMode = InsertionMode.Replace,
        LoadingElementId = "progress2",
        OnSuccess = string.Format(
            "disableform({0})",
            Json.Encode(item)),
    }))
    {  
        @Html.ValidationSummary(true)

        @Html.AntiForgeryToken()
        <td>
            @Html.DropDownList("LabTestID", String.Empty)
            @Html.ValidationMessageFor(model => model.LabTestID)
        </td>
        <td>
            @Html.EditorFor(model => model.Result)
            @Html.ValidationMessageFor(model => model.Result)
        </td>

        <td>
            @Html.EditorFor(model => model.DateTaken)
            @Html.ValidationMessageFor(model => model.DateTaken)
        </td>

        <td>
            @Html.EditorFor(model => model.Comment)
            @Html.ValidationMessageFor(model => model.Comment)
        </td>

        <td>
            <input type="submit" value="Create" />
        </td>

        <td id = @(item.ToString() + "td")>
        </td>
    }
    </tr>
    }
</table>
</code>

Und meine Aktionsmethode, die den ModelState.AddModelError definiert, sieht wie folgt aus:

<code>[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult CreateAll(VisitLabResult vlr, int visitid = 28)
{
    try
    {
        if (ModelState.IsValid)
        {
            var v = repository.GetVisit(visitid);
            if (!(v.EligableToStart(User.Identity.Name))){ 
                return View("NotFound"); 
            }
            vlr.VisitID = visitid;
            repository.AddVisitLabResult(vlr);
            repository.Save();

            return Content("Addedd Succsfully");
        }
    }
    catch (DbUpdateException)
    {
        JsonRequestBehavior.AllowGet);
        ModelState.AddModelError(string.Empty, "The Same test Type might have been already created,, go back to the Visit page to see the avilalbe Lab Tests");
    }
}
</code>

Also, wie kann ich den ModelState.AddModelError auf meiner Ansicht zeigen.

Antworten auf die Frage(3)

Ihre Antwort auf die Frage