ModelView List in asp.net form

Viewed 41

Pretty new in c# and i would need some help to understand something.

So i have a modelView like this

public class CreateGradeEventViewModel
    {
        public string Titre { get; set; }

        public DateTime Date { get; set; }

        public int SchoolId { get; set; }

        public List<karatekaGrade> karatekaGrades { get; set; }
    }

And a class karatekaGrade

public class karatekaGrade
{
    public int karatekaId { get; set; }

    public int gradeId { get; set; }
}

In JQuery im building an object like the karatekaGrade class and i want to bind it so that on submit i can receive this list.

I have no problem with the others input, they bind and i receive the data in my viewmodel in my controller, for example Titre is working perfect.

<div class="mb-3">
      <label asp-for="Titre"></label>
      <input asp-for="Titre" class="form-control"/>
      <span asp-validation-for="Titre" class="text-danger"></span>
</div>

So my question is whats the best way to pass value to

public List karatekaGrades { get; set; }

When i build my List in Jquery and do not have an input in my forms for this.

Thanks for your help

0 Answers
Related