单击视图中的不同链接时显示某些列表

时间:2015-03-10 09:51:28

标签: list asp.net-mvc-4 model-view-controller

每次点击视图中的不同链接时,我都需要显示不同的列表。帮助将不胜感激:))

我的控制器:

public class HomeController : Controller
{
    Teams tm = new Teams();
    Details det = new Details();

    public ActionResult Index()
    {
        var model = new List<Teams>();

        model.Add(new Teams { Name = "Manchester United", NickName = "The Red Devils", HomeGround = "Old Trafford", Founded = 1878 });
        model.Add(new Teams { Name = "Liverpool", NickName = "The reds", HomeGround = "Anfield", Founded = 1870 });

        return View(model);
    }

    public ActionResult About()
    {
        var title = new List<Details>();

        title.Add(new Details { MajorHonours = 62, PremLeague = 20, FACup = 11, LeagueCup = 4, UEFA = 3 });
        title.Add(new Details { MajorHonours = 60, PremLeague = 18, FACup = 7, LeagueCup = 8, UEFA = 5 });

        return View();
    }

我对链接的看法:

@model IEnumerable<Standings.Models.Teams>

@{
    ViewBag.Title = "Standings";
 }

<h1>List of teams</h1>

@foreach (var item in Model)
{
    <div>
       @Html.ActionLink(@item.Name, "About") (@item.NickName, @item.HomeGround, @item.Founded)
    <hr />
</div>

}

我的模特:

public class Details
{
    public int MajorHonours { get; set; }
    public int PremLeague { get; set; }
    public int FACup { get; set; }
    public int LeagueCup { get; set; }
    public int UEFA { get; set; }
}

我有一个名为About的干净视图,该列表需要显示在

0 个答案:

没有答案