我有一些代码:
<table>
@foreach (var invoiceLine in Model.Invoice.InvoiceLine)) {
<tr class="subheader">
<td>
<div class="approval">
<span>Office sign off:</span>
@Html.DisplayFor(modelItem => item.OfficeUser.Name)
<span id="officeapprovalspan">@(item.OfficeApproved.HasValue ? (item.OfficeApproved.Value ? "Accepted" : "On Hold") : "Please Approve")</span>
</div>
</td>
id="officeapprovalspan"
的跨度我希望设置它的id,以便它是officapprovalspan“x”,其中x是当前项目invoiceLineId。
因此,当invoiceLineId = 3时,理想情况下我希望范围ID为id="officeapprovalspan3"
任何人都知道如何实现这一目标?
答案 0 :(得分:5)
<span id="officeapprovalspan@(invoiceLine.invoiceLineId)">@(item.OfficeApproved.HasValue ? (item.OfficeApproved.Value ? "Accepted" : "On Hold") : "Please Approve")</span>
或
<span id="@("officeapprovalspan" + invoiceLine.invoiceLineId)">@(item.OfficeApproved.HasValue ? (item.OfficeApproved.Value ? "Accepted" : "On Hold") : "Please Approve")</span>
答案 1 :(得分:3)
怎么样:
<span id="officeapprovalspan@invoiceLine.InvoiceLineId">