How to set image Tag URLs programmatically in ASP.NET C# inside of a ListView Control?

Posted by loyalpenguin on Stack Overflow See other posts from Stack Overflow or by loyalpenguin
Published on 2010-05-05T15:49:39Z Indexed on 2010/05/05 15:58 UTC
Read the original article Hit count: 228

Filed under:
|
|
|

Hi, I know how you can set an tag's url attribute programmatically in c#, but it seems when I try to access the image element inside of a tag I cannot access it.

The is residing in the .

NOTE: I am only having this issue inside the

Now the ListView tag is also databound.(this is probably why I cannot access, because it isn't guaranteed that it will even exist perhaps).

How can I get around this so that I can display my images programmatically or is there a better solution?

Here's the source:

    <asp:ListView ID="ListView_Comments" runat="server"
DataKeyNames="ReviewID,ProductID,Rating" DataSourceID="EDS_CommentsList">
<ItemTemplate>
<tr style="background-color:#EDECB3;color: #000000;"> <td><%# Eval("CustomerName") %></td>
<td> <img src='Styles/Images/ReviewRating_d<%# Eval("Rating") %>.gif' alt="">
<br />
</td>
<td> <%# Eval("Comments") %>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color:#F8F8F8;"> <td><%# Eval("CustomerName") %></td>
<td> 
<img id="rateImage" src="" alt="" runat="server" />
......

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET