Instead of displaying the value of item.Endereco
in the WebGrid what is displayed is a text @ item.Endereco.Length > 0? item.Endereco.Substring (0, item.Endereco.Length - 3): item.Endereco . Home
In my current scenario I have to do this validation with substring
in View (in webgrid)
@grid.GetHtml(
tableStyle: "grid",
headerStyle: "head",
columns: grid.Columns(
grid.Column("Empresa", "Empresa"),
grid.Column("Nome", format: @<text><a href="@Url.Action("Index", "Home", new { id = item.Id})">@item.Nome</a></text>),
grid.Column("Endereco", format: @<text><a href="@Url.Action("Index", "Contato", new { id = item.Id})">@item.Endereco.Length > 0 ? item.Endereco.Substring(0, item.Endereco.Length - 3) : item.Endereco</a></text>)
)
)