0

如果我有一个中继器通过数据列表来检索我使用的值

<%# Eval("current_item") %>

运气好的话,它会输出“current_item”的信息

但是,如果我想检查“current_item”是否等于 1,这将告诉我是否打印下一批信息。那么如何使用该信息来确定输出,有效地我想将该信息放入一个变量中。

<%# myInt = int.Parse(Eval("current_item")) %>

上面的代码是我真正想做的。

然后我会做这样的事情:

<% if (myInt == 1) { %>
<p>Information to display if myInt = 1</p>
<% } else { %>
<p>Other Information</p>
<% } %>

有任何想法吗?

4

1 回答 1

0

我在 GridView 中使用了类似于以下内容的内容:

<p>
    <asp:Label Visible='<%# ((int)Eval("current_item") == 1) %>' Text="This is the first item" runat="server" />
    <asp:Label Visible='<%# ((int)Eval("current_item") != 1) %>' Text="This is not the first item" runat="server" />
</p>

试一试,看看它是否也适用于中继器。

于 2012-04-13T12:37:00.743 回答