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>
</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;
精彩评论