3
I have the following problem with my application. The course table is related to the Discipline table, that is, 1 Discipline belongs to several courses, and at the time of registering a course and adding more disciplines to this course I can not perform this action.
Screen print:


[Controller]
public ActionResult AddDisciplina(int id, Curso curso) { 
    @ViewBag.id = curso.CursoID=id; 
    ViewBag.d = new SelectList(db.disciplina, "DisciplinaID", "nome"); 
    return View(); 
}
[HttpPost, ActionName("AddDisciplina")]
[ValidateAntiForgeryToken]
public ActionResult AddDisciplina([Bind(Include = "CursoID,DisciplinaID")]Curso curso)
{
    return View();
}
[View]
<h2>AddDisciplina</h2> 
<div class="form-group"> 
     <div class="col-md-offset-2 col-md-10"> 
         <input type="hidden" id=" cursoID" name="cursoID" value="@ViewBag.id"> 
         @Html.DropDownList("d", null, htmlAttributes: new { @class = "form-control" }) 
     </div> 
</div> 
<br/> 
<div class="form-group"> 
     <div class="col-md-offset-2 col-md-10"> 
          <input type="submit" value="Create" class="btn btn-default" /> 
     </div> 
</div>
						
You can put in your question the code that performs this insertion?
– Leonel Sanches da Silva
Where is the
Actionthat the data persists? Tip: Also callsAddDiscipina, but it has a[HttpPost]on top.– Leonel Sanches da Silva