After selecting a value in a drop down list, I have a partial view being created. This partial view is based on the following ViewModel :
public class vm_ElevesCoursNotes
{
public List<Models.ELEVE> eleves { get; set; }
public Models.COURS cours { get; set; }
public List<Models.NOTER> notes { get; set; }
}
Models.NOTER is based on this Model :
[Table("NOTER")]
public partial class NOTER
{
[Key]
public int IDNOTER { get; set; }
public int IDELEVE { get; set; }
public int IDCOURS { get; set; }
[RegularExpression(@"^[0-9]{1}([.][0-9]{1})?$", ErrorMessage = "bad grade format")]
public float NOTE { get; set; }
public short NUMERO_NOTE { get; set; }
public virtual COURS COURS { get; set; }
public virtual ELEVE ELEVE { get; set; }
}
Inside my partial view, I want to add @Html.EditorFor the field NOTE for each item of the List notes.
I tried the following method after browsing a lot of topics :
@model pwanSprint1.ViewModels.vm_ElevesCoursNotes
@using (Html.BeginForm("validerNotes", "GestionNotes", FormMethod.Post, new { id = "lstEleves"))
{
foreach(var note in Model.notes)
{
@Html.EditorFor(note => note.NOTE)
@Html.ValidateFor(note => note.NOTE)
}
}
For the moment I wrote some HTML code and tried to do some client side custom jQuery validation but nothing seem to work.
The objective is to list students from a certain class and all the grades they have. I should also be able to insert data where the grades are not filled yet. Something like the following screenshot.
What am I doing wrong ? Is there something simple I don't understand ?
PS : I'm a complete beginner in MVC, sorry.