我對razor
視圖引擎不是很熟悉。我試過這個代碼。asp.net中的數據庫訪問
@for(var item in ViewBag.list)
{
@foreach (var itemvote in ViewBag.listVote)
{
<h1>@Html.ActionLink(@item.Title, "Details", "Report", new { id = item.Id},null)</h1>
}
}
And it shows the following error:
編譯器錯誤信息:CS1973:「System.Web.Mvc.HtmlHelper」有一個名爲「ActionLink的」沒有適用的方法,但似乎有這個名字的擴展方法。擴展方法不能動態分派。考慮轉換動態參數或調用擴展方法而不使用擴展方法語法。
我的控制器類是ReportController
,方法是Details
它將被提交。
public ActionResult Details(int id = 0)
{
Report report = Context.Reports.Find(id);
if (report == null)
{
return HttpNotFound();
}
ViewBag.report = report;
return View();
}
我用Google搜索,發現類似HTML.ActionLink method
一些鏈接,但我仍然無法糾正。
我解決了這個問題,並
@Html有效簽名.ActionLink((string)@ item.Title,「Details」,new {id = item.Id})
這一行是我的答案.. – 2013-05-06 11:11:57