I have the following problem in my application.The course table is related to the Discipline table, ie 1 Discipline belongs to several course, and at the time of registering a course and adding more courses to this course I can not accomplish this action. Print the screens:
[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>