开发者

How to display dynamic Html.ActionLink label?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜