razor - Database access in asp.net -


i not familiar razor view engine. tried code.

@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 shows following error:

compiler error message: cs1973: 'system.web.mvc.htmlhelper' has no applicable method named 'actionlink' appears have extension method name. extension methods cannot dynamically dispatched. consider casting dynamic arguments or calling extension method without extension method syntax.

my controller class reportcontroller , method details submitted.

public actionresult details(int id = 0)         {             report report = context.reports.find(id);             if (report == null)             {                 return httpnotfound();             }             viewbag.report = report;              return view();         } 

i googled , found link html.actionlink method

but still unable correct it.

there @ least 2 problems call actionlink.

first, first parameter not require '@' because you're using 1 @ start of line @html.actionlink.

secondly, first parameter should itemvote.title not item.title, don't have variable called item.

that part of problem, because compiler might not realize @item.title supposed string, , there valid signature of actionlink(string, string, string, object, object)


Comments