Skip to content Skip to sidebar Skip to footer

Display Image Via Imageurl In Listview

Not sure how to explain this but I have a mysql syntax odbc connection bound to a sqldatasource like so:

Solution 1:

You can not use a server control in template part of other server controls.

but the only solution is inserting img tag in your template. but a problem still remains. your image url maybe have ~ indicating application Path.

You can use code bellow to correct this problem too.

<img alt="" src="<%# Eval("picturepath").Tostring()
     .Replace("~/", "http://" + Request.Url.Host + "/" + 
     (string.IsNullOrEmpty(Request.ApplicationPath)?
         string.Empty:Request.ApplicationPath + "/") %>" />

This will correct your problem

Solution 2:

Change double quotes " " to single quote ' ':

src="<%# Eval("picturepath") %>" /> 

to

src='<%# Eval("picturepath") %>' />

Post a Comment for "Display Image Via Imageurl In Listview"