简体   繁体   English

我如何将图像绑定到 <asp:Image /> 表单视图中的标签

[英]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. 首先,我有一个getProfileImage.aspx,它接受CusID和TN作为查询字符串并显示n个图像。 So getProfileImage.aspx?CusID=10&TN=Y will show the image fine in the browser :) 所以getProfileImage.aspx?CusID = 10&TN = Y将在浏览器中很好地显示图像:)

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... 现在,我看到一个窗体视图,我想绑定图像的src以从getProfileImage.aspx页面获取图像...

The following code works fine :) 10 is the customer ID and the image is working fine... 以下代码可以正常工作:) 10是客户ID,图像正常工作...

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

But now i want to Bind the CusID value... 但是现在我想绑定CusID值...

<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... 这根本行不通:(用CusID = <%...调用getProfileImage.aspx,在我看来,<%#Bind(“ CusID”)%>的方式不是由ASP解析的,ASP会返回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! 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 :) :) {0}替换为CusID,这正是我想要的:)非常感谢Robin Day也为您提供帮助:) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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