0

WebGridの条件付き列に2つのHtml.ActionLinkを連結しようとしています。そのようなもの:

@grid.GetHtml(columns:grid.Columns(
   grid.Column("AccountNumber"),
   grid.Column("ContractNumber"),
   grid.Column("DisplayName"),
   grid.Column("IsFinalized"," ",format:(item) => (item.IsFinalized == true) 
     ?@<text> @Html.ActionLink("Edit", "Edit", new { accountId = item.AccountNumber}) | @Html.ActionLink("Details", "Details", new { accountId = item.AccountNumber }) </text>
     :@<text> @Html.ActionLink("Validate", "Validate", new { accountId = item.AccountNumber} | @Html.ActionLink("Details", "Details", new { accountId = item.AccountNumber }))</text>)
))
4

1 に答える 1

2

以下を使用して解決策が見つかった場合:

 new HtmlString()

したがって、この:

grid.Column("IsFinalized"," ",format:(item) => (item.IsFinalized == true) 
     ?@<text> @Html.ActionLink("Edit", "Edit", new { accountId = item.AccountNumber}) | @Html.ActionLink("Details", "Details", new { accountId = item.AccountNumber }) </text>
     :@<text> @Html.ActionLink("Validate", "Validate", new { accountId = item.AccountNumber} | @Html.ActionLink("Details", "Details", new { accountId = item.AccountNumber }))</text>)

与える:

grid.Column("IsFinalized", " ", format: item => (item.IsFinalized == true)
    ? new HtmlString( Html.ActionLink("Edit", "Edit", new { accountId = item.AccountNumber }).ToString() + "|" + Html.ActionLink("Details", "Details", new { accountId = item.AccountNumber }).ToString())
    : new HtmlString( Html.ActionLink("Validate", "Validate", new { accountId = item.AccountNumber }).ToString() + "|" + Html.ActionLink("Details", "Details", new { accountId = item.AccountNumber }).ToString())
于 2013-03-26T09:11:07.333 に答える