Click to See Complete Forum and Search --> : Detailsview on evaluting image from DB?


BobotheBugbear
03-14-2006, 01:07 PM
Here is the weird part:

I am retrieving an image from the DB and I have in my image control like this:

<asp:Image ID="Image1" runat="server" Height="40px" ImageUrl='imageView.aspx?username=<%# Eval("UserName") %>' />

This then evaluates to after viewing the source to:

<img id="ctl00_bodyContent_dvThemeColors_Image1" src="imageView.aspx?username=&lt;%#
Eval(&quot;UserName&quot;) %>" style="height:40px;border-width:0px;" />

You'll see that the username which should be there isn't as it writes it out as complete HTML. Username is valid.

What is the cause of this and how can I get it to eval correctly so that I can retrieve the image from the DB?

thanks

ps. this is in a detailsview if that matters

takkie
03-14-2006, 02:26 PM
b/c the webserver is rendering your imageUrl as a whole string.. instead of doing the Eval..

try this,

ImageUrl="imageView.aspx?username=" & '<%# Eval("username") %>' />

or this (i dont remember if it uses the & or not...)

ImageUrl = '<%# getImageURL(Eval("username")) %>' />

and setup a protected or public function called, getImageURL in your codebehind, and make it do this,

protected function getImageURL(string n)
return "imageView.aspx?username " & n
end fucntion

-tak