MVC5 did a great job on automatically creating the View page (Razor). It currently displays my list of Students for example with table heading like this:
<th>
@*@Html.ActionLink("", "Index", new { sortOrder = ViewBag.NameSortParm })*@
@Html.DisplayNameFor(model => model.LastName)
</th>
Now. DisplayNameFor take a Lambda Expression as its parameter.
However, I want the Column title, which is "Last Name", to pass into another HtmlHelper's parameter - ActionLink's.
Following articles seem to be similar but I read it, unfortunately it didn't solve my problem:
Why don't you use Resources for this:
Your model will look like:
public class Model
{
[Display(Name = "LastNameTitle ", ResourceType = typeof(Resources.Resources))]
public string LastName{ get; set; }
}
Your View:
<th>
@Html.ActionLink(Resources.Resources.LastNameTitle , "Index", new { sortOrder = ViewBag.NameSortParm })
@Html.DisplayNameFor(model => model.LastName)
</th>