gpt4 book ai didi

Kentico Repeater HTML 属性显示选定的转换

转载 作者:行者123 更新时间:2023-12-03 03:27:33 25 4
gpt4 key购买 nike

我的 HTML 信封将我的转发器转换包装在 TABLE 标记中。如果不使用 JS,我如何确保此 HTML 对于所选转换不可见。我不反对为所选转换数据提供一个模板,只是不确定如何做到这一点。

这是我的转变:

<tr>
<td><%# FormatDate(Eval("Date")) %></td>
<td><a href="<%# GetDocumentUrl() %>"><%# Eval("Subject") %></a></td>
<td><%# Eval("From") %></td>
</tr>

这是我选择的转换:

<section id="memoDetail">
<h1>Memorandum</h1>
<ul id="memoHeader">
<li><span class="headerLabel">To:</span> <%# Eval("To") %></li>
<li><span class="headerLabel">From:</span> <%# Eval("From") %></li>
<li><span class="headerLabel">Subject:</span> <%# Eval("Subject") %></li>
<li><span class="headerLabel">Date:</span> <%# Eval("Date") %></li>
</ul>
<div id="memoDetails"><%# Eval("Details") %></div>
</section>

最佳答案

考虑将表格标签从 html 信封中移出,并有条件地在转换中渲染它们,如下所示:

// If this is the first item in the repeater, open the table tag
<%# DataItemIndex == 0 ? "<table>" : "" %>

// your trasformation code

// if this is the last item in the repeater, close the table tag
<%# DataItemIndex + 1 == DataItemCount ? "</table>" : "" %>

这将阻止它们出现在您所选项目的转换中,因为这是完全不同的转换。

您可能必须将 DataItemIndex 和 DataItemCount 属性放置在 Eval() 方法中。我已经有一段时间没有使用 ASCX 转换了。

编辑: 看来您现在可以在 ascx 转换中使用 IsFirst()IsLast() 方法:

<%# IsFirst() ? "<table>" : "" %>

// transformation code

<%# IsLast() ? "</table>" : "" %>

关于Kentico Repeater HTML 属性显示选定的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35435529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com