开发者

Conditional Display in a ListView

I have the following ListView code:

<asp:ListView ID="lvOrders" runat="server">
    <LayoutTemplate>    
        <ul id="orderList">
            <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
        </ul>
    </LayoutTemplate>

    <ItemTemplate>
        <li>           
            <% if (Mode == AdminSingle) { %>                    
                <%# Eval("Offertype")%>
            <% } %>
        <%# Eval("Something")%>
        </li>
    </ItemTemplate>
</asp开发者_运维百科:ListView>

Now, my problem is that Eval("Offertype") is being evaluated in any case. But the sql query is pretty heavy for that part and I would like to only run that part of the query if I really need too. Is there a clean way around this?

I know I could do this:

<%# GetStatusInfo(Container.DataItem)%>

But then I get the display logic into my code....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜