2

我有一些代码,例如:

<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"我想设置它的跨度,以便它是 officapprovalspan"x",其中 x 是当前项目 invoiceLineId。

因此,当 invoiceLineId=3 理想情况下,我希望跨度 ID 为id="officeapprovalspan3"

任何人都知道如何实现这一目标?

4

2 回答 2

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>
于 2012-04-11T21:06:29.817 回答
3

怎么样:

<span id="officeapprovalspan@invoiceLine.InvoiceLineId">
于 2012-04-11T21:03:28.743 回答