Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2732
Column Template ActionLink
posted

Hello,

I'm trying to have a column with a template to display a link. 

The following template works: "<a href='/DevOps/SoftwareInformation/Filter/${Name}'>${Name}</a>"
However, I would like to create a Html.ActionLink to directly link to the controller & action. 

In my cshtml file this is how I would do it:
@Html.ActionLink(linkText:"Test Filter", actionName:"Filter", controllerName:"SoftwareInformation", routeValues:new { id="Test"}, htmlAttributes:null)

However, I don't manage to translate this to a column template. Everything I try just gets translated to pure text.

This is the code I use to define the column:

model.Columns.Add(new GridColumn("Name", "Name", "string", "220px") {
    Template = @"Html.ActionLink(linkText:""${Name} Filter"", actionName:""Filter"", controllerName:""SoftwareInformation"", routeValues:new { id=""${Name}""}, htmlAttributes:null)"});

Any advice ?

Kind regards,

Michael

Parents Reply Children
No Data