0

I am not very much familiar with razor view engine. I tried this 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 it shows the following error:

Compiler Error Message: CS1973: 'System.Web.Mvc.HtmlHelper' has no applicable method named 'ActionLink' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

my controller class is ReportController and method is Details to which it will be 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 and found some link like HTML.ActionLink method

but i am still unable to correct it.

1 Answer 1

0

There are at least 2 problems with your call to actionlink.

First, the first parameter does not require a '@' because you're already using one at the start of the line with @Html.ActionLink.

Secondly, the first parameter should be itemvote.Title not item.Title, as you don't have a variable called item.

That could be part of your problem, because the compiler might not realize that @item.Title is supposed to be a string, and there is a valid signature of ActionLink(string, string, string, Object, Object)

Sign up to request clarification or add additional context in comments.

1 Comment

i solved that problem and <h1>@Html.ActionLink((string)@item.Title, "Details", new { id = item.Id})</h1> this line is my answer..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.