简体   繁体   中英

How do i bind an image to a <asp:Image /> tag in Form View

First i have a getProfileImage.aspx which accepts a CusID and TN as query strings and display n image. So getProfileImage.aspx?CusID=10&TN=Y will show the image fine in the browser :)

But...

Now i am presented with a Form View and i want to bind the src of the image to get the image from the getProfileImage.aspx page...

The following code works fine :) 10 is the customer ID and the image is working fine...

<asp:Image ID="Image1" runat="server" Height="151px" ImageUrl='~/getProfileImage.aspx?CusID=10&TN=N' />

But now i want to Bind the CusID value...

<asp:Image ID="Image1" runat="server" Height="151px" ImageUrl='~/getProfileImage.aspx?CusID=<%# Bind("CusID") %>&TN=N' />

This simply does not work :( The getProfileImage.aspx is called with CusID=<%... where the way i see it the <%# Bind("CusID") %> is not parsed by ASP which would have returned 10...

<%# Bind("CusID") %>

The above tag alone will work... but inserting it to the middle of the tag seems to break it...

Any suggestions ? Thanx a lot in advance :)

Yeyy! :) I found the answer :)

ImageUrl='<%# Eval("CusID", "getProfileImage.aspx?CusID={0}&TN=N") %>' 

The {0} is replaced by the CusID which is just what i wanted :) Thanx a lot Robin Day for your help too :) :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM