Hey
asp.net 2.0
I have a repeater control in my webpage (you see my code below). In this
control's ItemDataBound event I set the ImageUrl of a Image object. My
problem is that when I run this webpage it shows only 1 image... -the
repeater displays 2 rows, but it's only the first row that displays the
image...
I want each repeater row to display it's image, Any ideas what I should do
to fix this?
This is my repeater control in my webpage:
<asp:Repeater ID="rptInbox" runat="server" DataSourceID="odsInbox"
OnItemDataBound="rptInbox_ItemDataBound">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td bgcolor="#CCFFCC">
<%# Eval("Name") %>
<asp:Image ID="photo" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
In this ItemDataBound I have this code:
protected void rptInbox_ItemDataBound(object sender, RepeaterItemEventArgs
e) {
System.Web.UI.WebControls.Image img = null;
if (e.Item.ItemType == ListItemType.Item){
img = (System.Web.UI.WebControls.Image)e.Item.FindContro l("photo");
img.ImageUrl = "~/images/test.jpeg";
}
}
I know this line "img.ImageUrl = "~/images/test.jpeg";" may look strange,
but I'm hardcoding this now to see if I get the images displayed correctly.
When images are displaying correctly then I will modify that line to display
images dynamica
This is the html source taken from the browser:
<table>
<tr>
<td bgcolor="#CCFFCC">
test1
<img id="ctl00_content_rptInbox_ctl01_photo"
src="../../images/test.jpeg" style="border-width:0px;" />
</td>
</tr>
<tr>
<td bgcolor="#CCFFCC">
test2
<img id="ctl00_content_rptInbox_ctl02_photo" src=""
style="border-width:0px;" />
</td>
</tr>
</table>
lly