Error creating a condition in the Html.Raw of the WebGrid

0

I'm trying to put a condition on a WebGrid line and the following error occurs: Cannot convert lambda expression to type 'string' because it is not delegate type

EventhoughI'mbasingmyselfonthispost# with credits from MeAjudaSilvio I can not make it work:

grid.Column(Model.DescricaoServico_002, format: (item) =>
{
    if (item.Status == 1)
    {
        return Html.Raw(@<text><div><a href="@Url.Action("ExportarPDFSelecionado", "ProcessamentoRegistros", new { idprocessamentodiario = item.IdProcessamentoDiario, idservico = item.Servico_002.Length > 0 ? item.Servico_002.Substring(item.Servico_002.Length - 3, 3) : item.Servico_002 })" target='_blank'>@(item.Servico_002.Length > 0 ? item.Servico_002.Substring(0, item.Servico_002.Length - 3) : item.Servico_002)</a></div></text>);
    }
    else
    {
        return Html.Raw("<font color='red'><b>Inativo</b></font>");
    }
}),
    
asked by anonymous 14.06.2017 / 05:51

1 answer

0

Resolved by putting the tag inside a String.format :

return Html.Raw(string.Format("<text><div><a href=\"{0}\" target='_blank'>{1}</a></div></text>", @Url.Action("ExportarPDFSelecionado", "ProcessamentoRegistros", new { idprocessamentodiario = item.IdProcessamentoDiario, idregistro = item.IdRegistro, Parametro = item.Parametro, idservico = item.Servico_002.Length > 0 ? item.Servico_002.Substring(item.Servico_002.Length - 3, 3) : item.Servico_002 }), item.Servico_002.Length > 0 ? item.Servico_002.Substring(0, item.Servico_002.Length - 3) : item.Servico_002));
    
14.06.2017 / 16:51