<div class="collapse" id="divRows-@item.BandeiraAdministradoraId">
@foreach (var taxa in item.TaxaBandeiraAdministradoras)
{
<div style="padding-left: 100px;">
@Html.DisplayFor(modelItem => taxa.NumeroTaxas, new { @class = "text-uppercase" })
@Html.Raw("X =")
@Html.DisplayFor(modelItem => taxa.ValorTaxa, new { @class = "text-uppercase" })
@Html.Raw("%")
<br />
</div>
}
</div>
答案 0 :(得分:0)
您只需在您的ID中添加数字即可使其唯一,或根据您的某些模型数据制作此ID:
@{int i = 0;}
@foreach(var myItem in Model.Members)
{
<span id="name_@(i)">test</span>
i++;
}
答案 1 :(得分:0)
将for-each
替换为经典for-loop
并使用其索引器。
//... some code
else
{
for (int i = 1; i <= item.TaxaBandeiraAdministradoras.Count; i++)
{
var taxa = item.TaxaBandeiraAdministradoras[i];
<div id="@(i.ToString())">Example Div with Id @(i.ToString()) from Loop</div>
<div style="padding-left: 100px;" id="demo-@item.BandeiraAdministradoraId" class="collapse">
<div style="float: left;">
@Html.DisplayFor(modelItem => taxa.NumeroTaxas, new {@class = "text-uppercase"})
@Html.Raw("X =")
</div>
<div style="float: left">
@Html.Raw(" ")
@Html.DisplayFor(modelItem => taxa.ValorTaxa, new {@class = "text-uppercase"})
@Html.Raw("%")
</div>
</div>
<br/>
}
}