开发者

Conditional Display in a ListView

开发者 https://www.devze.com 2023-02-19 17:10 出处:网络
I have the following ListView code: <asp:ListView ID=\"lvOrders\" runat=\"server\"> <LayoutTemplate>

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

精彩评论

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