Use the 'If condition' in Item Template [ASP]

后端 未结 1 1611
时光说笑
时光说笑 2020-12-04 04:31

I have two elements; and > in an ItemTemplate, I want to test the value <% # Eval (\"Url\")%>

相关标签:
1条回答
  • 2020-12-04 04:41

    You can use a ternary operator in the template and based on that outcome show/hide the correct element.

    <ItemTemplate>
        <li>
            <asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible='<%# Eval("SomeValue").ToString() == "video" ? true : false %>'>
    
                <video data-cycle-cmd="pause" id='my-video' class='video-js' controls preload='auto' width='980' height='452' poster='MY_VIDEO_POSTER.jpg' data-setup='{}'>
                    <source src='<%# Eval("Url") %>' type='video/mp4'>
                </video>
    
            </asp:PlaceHolder>
    
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Url") %>' Visible='<%# Eval("SomeValue").ToString() == "video" ? false : true %>' />
        </li>
    </ItemTemplate>
    
    0 讨论(0)
提交回复
热议问题