Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# ASP.NET MVC Basics Adding a List Page Creating Hyperlinks

Calvin Secrest
Calvin Secrest
24,815 Points

Bummer! Did you use the 'videoGame.DisplayText' property value for the 'ActionLink' helper method link text parameter...

Bummer! Did you use the 'videoGame.DisplayText' property value for the 'ActionLink' helper method link text parameter value?

Update the Index.cshtml view to display each VideoGame.DisplayText property value as a hyperlink to the detail view.

Within the provided <li> element, render a hyperlink using the Html.ActionLink method. For the link text, use the videoGame.DisplayText property value. For the action name, use the string literal Detail. For the route values, instantiate an anonymous object with an id property set to the videoGame.Id property value.

Need help....

Index.cshtml
@model Treehouse.Models.VideoGame[]

@{
    ViewBag.PageTitle = "Video Games";  
}

<h1>@ViewBag.PageTitle</h1>

<div>
    <ul>
        @foreach (var videoGame in Model)
        {
            <li>@Html.ActionLink("videoGame.DisplayText", new {action="Detail"}, new {id = videoGame.Id)</li>
        }
    </ul>
</div>

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! There are a couple of things going on here. First, you're sending in the videoGame.DisplayText as a string. This is incorrect. Secondly, you're supposed to send in "Detail" as a string literal. And thirdly, you're missing a closed curly brace after the creation of the id. Take a look:

<li>@Html.ActionLink(videoGame.DisplayText, "Detail", new { id = videoGame.Id })</li>

Here we create our link by passing in the name of the method (not as a string), then "Detail" as a string literal, and finally, we create the new id for our video game.

Hope this helps! :sparkles:

Calvin Secrest
Calvin Secrest
24,815 Points

Thank you so much for the assistance with this code challenge!