I am developing the CRM and facing some troubles in model validation.The process looks simple when only one object in the model(i am using EF) is validated on the form. But when i am trying to process validation on multiply objects, only one top record got validated. Here is the code:
@model List<CROS1.Models.GetParams_Result> //
<h3 align="center">
Please fill report params
</h3>
<div class="sidebar_item">
@using (@Ajax.BeginForm("ConfirmGeneration", "Home", ajaxOptions: new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "params",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "resultLoadingDiv",
}, htmlAttributes: new { id = "Form2" }))
{
<table id="hor-minimalist-b">
<tread>
<tr>
<th scope ="col">Report</th>
<th scope ="col">Filter</th>
<th scope ="col">Value</th>
</tr>
</tread>
@foreach (CROS1.Models.GetParams_Result res in Model)
{
<tbody>
<tr>
<td>@Html.DisplayTextFor(r => res.R_name)
</td>
<td>@Html.DisplayTextFor(r => res.Filter_name)
</td>
<td>@Html.EditorFor(r => res.Value)
@Html.ValidationMessageFor(r=>res.Value)
</td>
<td>@Html.DisplayFor(r => res.Unity)
</td>
@Html.HiddenFor(r=>res.F_id)
@Html.HiddenFor(r=>res.R_id)
@Html.HiddenFor(r=>res.Filter_id,new{id="some"})
@Html.HiddenFor(r => res.F_name)
@Html.HiddenFor(r => res.Filter_name)*@
@Html.HiddenFor(r=>res.DefaultValue)
@Html.HiddenFor(r=>res.Visibles)
</tr>
</tbody>
}
</table>
@* <input type="submit" id="submGetParams" />*@
}
</div>
What i should do in this case? How the model must look like to be able to perform such validation?