-1

I have this ActionLink into view named catalog

@Html.ActionLink("Formations", "Index", "Formation", new { id = item.Id },null)

and I want to get the list of formations of this catalog id.

How can I do this ?

In my database I have two tables :

Catalog:idC (PK),NameC,Date
Formation:idF(PK),idC(FK),NameF.
Andrei
  • 55,890
  • 9
  • 87
  • 108
dhouha babay
  • 73
  • 3
  • 13

1 Answers1

0

If your view's name is Catalog, you need to change your ActionLink to point to the corresponding action:

@Html.ActionLink("Formations", "Catalog", "Formation", new { id = item.Id }, null)

action:

public ActionResult Catalog(int id)
{
  var formations = db.Formations.Where(f => f.idC == id).ToList;

  return View(formations);
}

view:

@model IEnumerable<ProjectName.Models.Formation>
// loop your formations
@foreach (var item in Model)
{
  // each formation iteration loops here
}
Eckert
  • 690
  • 4
  • 9