I have a database and I’m storing images in it along with a person’s name, and other attributes. I’ve databound my listview with a stored procedure. I want to know how I can display an icon on a row depending on if the record for that row has a picture or not for the person…
I’m not sure how to accomplish this however with the templates in asp.net
If you need me to provide any additional info I can.
Thanks.
EDIT:
Here is my template and the s where I’m hoping to put them.
<ItemTemplate>
<tr style="">
<td class="width100">
<asp:Image ID="Image1" runat="server" ImageUrl="./Images/PlayerPictures/nothing.gif" title="Picture Available" CssClass="icon right" />
<asp:Image ID="Image2" runat="server" ImageUrl="./Images/PlayerPictures/nothing.gif" title="Charts Available" CssClass="icon right" />
<asp:Image ID="Image3" runat="server" ImageUrl="./Images/PlayerPictures/nothing.gif" title="Reports Available" CssClass="icon right" />
<asp:Image ID="Image4" runat="server" ImageUrl="./Images/PlayerPictures/nothing.gif" title="Video Available" CssClass="icon right" />
</td>
<td class="width350">
<a href="?team=<%# TeamNumber() %>&player=<%# Eval("PlayerKey") %>"><asp:Label ID="PlayerLabel" runat="server" Text='<%# Eval("Player") %>' /></a>
</td>
<td>
<asp:Label ID="PositionLabel" runat="server" Text='<%# Eval("Position") %>' />
</td>
</tr>
</ItemTemplate>
I have no code-behind that is relevant I don’t think because the Listview is databound like so…
<asp:ListView ID="ListView4" runat="server"
DataSourceID="ListViewPlayersWithFilter"
DataKeyNames="PlayerKey">
You can use
ListView.ItemDataBoundEvent to display an image based on the column value:Aspx:
Code Behind: