@model IEnumerable @helper Truncate(string input, int length) { if (input.Length <= length) { @input } else { @input.Substring(0, length)... } } @{ ViewBag.Title = "Index"; }

Index

@Html.ActionLink("Create New", "Create")

@foreach (var item in Model) { }
Genre Artist Title Price
@Html.DisplayFor(modelItem => item.Genre.Name) @Truncate(item.Artist.Name, 25) @Truncate(item.Title, 25) @Html.DisplayFor(modelItem => item.Price) @Html.ActionLink("Edit", "Edit", new { id=item.AlbumId }) | @Html.ActionLink("Details", "Details", new { id=item.AlbumId }) | @Html.ActionLink("Delete", "Delete", new { id=item.AlbumId })