我有一个ActionResult Details()
// RETREIVE THE INDIVIDUAL DETAILS SHOWS
public ActionResult Details(int id)
{
var item = from s in db.Shows.Where(si => si.ShowId == id) select s;
return View(item);
}
}
更新的ul现在如下:
<div id = "browseShow"> <ul>
@foreach (var item in Model)
{
<li class = "lihead">
@item.Title
</li>
<li class = "lihead">
@item.Director.Name
@Html.ActionLink((string)item.Director.Name, "Index" "Director", new { director = item.Director.Name }, null)
</li>
<li>
<i>@item.Synopsis</i>
</li>
<li class = "lihead">
Price per ticket £
@item.Price
</li>
}
我更新了索引方法以接收字符串:
public ActionResult Index(string director)
{
return View();
}
答案 0 :(得分:2)
您对Html.ActionLink
试试这个
@Html.ActionLink(item.Director.Name.ToString(), "Index", "Director", new { director = item.Director.Name }, null)
现在你正在传递RouteValues作为HtmlAttributes。末尾的额外空值将调用正确的空值。
原始帖子已删除,但您也在director
属性下传递了导演名称,但您的方法正在接收int id
。你也需要解决这个问题。