Basically in your view you can do: <td id="[email protected]">
Follow an example
Model
public class Fruta
{
public int FrutaId { get; set; }
public string NomeFruta { get; set; }
}
Controller
public IActionResult Index()
{
var listaFruta = new List<Fruta>
{
new Fruta { FrutaId = 1, NomeFruta = "Pera" },
new Fruta { FrutaId = 2, NomeFruta = "Uva" },
new Fruta { FrutaId = 3, NomeFruta = "Maçã" },
new Fruta { FrutaId = 4, NomeFruta = "Salada Mista" }
};
return View(listaFruta);
}
View
@model IEnumerable<WebApplication1.Models.Fruta>
@{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.FrutaId)
</th>
<th>
@Html.DisplayNameFor(model => model.NomeFruta)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td id="[email protected]">
@Html.DisplayFor(modelItem => item.FrutaId)
</td>
<td>
@Html.DisplayFor(modelItem => item.NomeFruta)
</td>
</tr>
}
have you tried removing double quotes from your c#? For example:
<td id='[email protected]'>@relatorioDTO.Nome</td>
– William
Tried to use the
@Html.Raw()
?– Ronaldo Araújo Alves
used and it worked!! I will update my post to suddenly help someone. Thank you.
– Rafaela Marraschi
solved in this way:
@Html.Raw("<td class='largura20' id='permiteCertificacao" + @relatorioDTO.Identificador + "'>" + @relatorioDTO.Nome + "</td>");
– Rafaela Marraschi