0

My question is very similar to this:

Show images in Repeater control

The selected answer to that question is this:

<asp:Image ID="Image1" height="32" width="32" runat="server" 
  ImageUrl='<%# Eval("ImageUrl") %>' />

However, in my case, I have a pre-selected filename path. I've tried this and it doesn't work:

<asp:Image ID="Image1" height="32" width="32" runat="server" 
  ImageUrl='D:\MyPics\Photos\<%# Eval("PhotoLink") %>' />

The Eval doesn't get converted to anything, and when I look at my source after the page is rendered it says:

<img src="D:\MyPics\Photos\&lt;%#Eval(&quot;PhotoLink&quot;)%

I'm sure it's something really stupid, but I can't figure it out.

Johnny Bones
  • 8,786
  • 7
  • 52
  • 117

1 Answers1

1

Just use string formatting:

ImageUrl='<%# string.Format("D:\MyPics\Photos\{0}", Eval("PhotoLink")) %>'
Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
  • I had to change the "\" to "/" or it prompted me with an error, but that seemed to work. The image isn't showing up, but that's probably a different question because the "" tag is showing up properly. – Johnny Bones Jan 08 '18 at 00:24