Binding Eval with an ImageURL in ASP.NET
问题 I'm trying to bind an image using Eval() with VB.NET and ASP.NET, but am running into issues: Code snippet <bri:ThumbViewer Id="Th1" runat="server" ImageUrl='<%# Eval("Name", "~/SiteImages/ram/3/{0}") %>' Height="100px" Width="100px" /> I set strImagePath in the code-behind as: strImagePath ="~/SiteImages/ram/3/" How can I replace: ~/SiteImages/ram/3/{0} with the variable strImagePath ? 回答1: simply use <asp:Image id="abc" ImageUrl =<%# string.Format("~/SiteImages/ram/3/{0}",Eval("imagepath"))