开发者

ASP.NET repeater item retrieve and change property

I have the following <asp:repeater>:

<asp:Repeater ID="Repeater1" runat="server" DataSource='<%# Bind("Photos") %>' OnItemCreated="Repeater1_itemCreated" >
    <ItemTemplate>
        <div class="thumbs">
            <a href='Images/Parts/Photos/<%# Eval("PhotoId") %>.jpg' 
               开发者_C百科rel="lightbox-parts">
            <img id="smallPhotoImg" alt="" width="70px" height="70px" 
                 src='Images/Parts/Thumbs/<%# Eval("PhotoId") %>.jpg' />
            </a>&nbsp;&nbsp;
        </div>
    </ItemTemplate> 
</asp:Repeater>

It displays all images for needed "Part" but what I need is to hide the image i.e repeater item if Photos.IsDefault == true

How do I do this?


I have arrived at a solution:

The purpose was to hide the img. Photos.isDeFault is a database field:

This is what I came up with:

Photo photo = (Photo)e.Item.DataItem;
if (photo != null)
    if (photo.IsDefault)
        e.Item.Visible = false;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜