开发者

How to display dynamic Html.ActionLink label?

开发者 https://www.devze.com 2023-03-16 18:31 出处:网络
This code works, but displays \"Details\" for every row of my table: @appsGrid.GetHtml( tableStyle: \"table\",

This code works, but displays "Details" for every row of my table:

    @appsGrid.GetHtml(
    tableStyle: "table",
    headerStyle: "head",
    alternatingRowStyle: "alt",
             columns: appsGrid.Columns(
                 appsGrid.Column(columnName: "Code",
                                 header: "",
                                          format: (item) => Html.ActionLink("Details",
                                                                   "Index",
                                                                   "ApplicationTechStack",
                                                                   new {Code = item.Code},
                                                                   null
                                                                  ),

Howeve开发者_如何学Gor, when I try to change the line to format: (item) => Html.ActionLink(item.Code, it gives me error. How come? item is of class that has Code property, as visible in other parts - returns routing values just fine... What needs to be done to display the hyperlink text dynamically? Oh, I'm on MVC 3.


Try this. Displaytext is your dynamic value.

`columns: appsGrid.Columns(
          appsGrid.Column(columnName: "Code",
                  header: "",
                  format: (item) => Html.ActionLink((string)item.DisplayText,  
                                   "Index",
                                   "ApplicationTechStack",
                                   new {Code = item.Code},
                                   null),
0

精彩评论

暂无评论...
验证码 换一张
取 消