我的Web应用程序从数据库中检索图像的位置。我想使用图像控件在listview中显示图像。虽然我的数据库提供了我的图像的正确位置,但由于某种原因,我的Web应用程序无法呈现图像文件。 (当我将相同的地址放在另一个图像控件中时,图像会出现。)有没有人知道这件事?提前致谢。我在listview中的代码是:
<ItemTemplate>
<td runat="server" style="">
<asp:Image ID="albumImage" ImageURL = '<%# Eval("imgLocation") %>' runat="server" AlternateText= '<%# Eval("imgLocation") %>' /><br />
<asp:Label ID="albmNameLabel" runat="server" Text='<%# Eval("albmName") %>' />
<br />
</td>
</ItemTemplate>
我的网络应用程序部分生成的HTML是:
<td style="">
<img id="ListView1_albumImage_0" src="C:\odaiba.png" alt="C:\odaiba.png" /><br />
<span id="ListView1_albmNameLabel_0">tokyo trip</span>
<br />
</td>
答案 0 :(得分:1)
我强烈建议你在你的网络项目中创建一个C:\
文件夹并更新你的数据库以引用具有相对路径的图像:{{1>而不是将图像放在images
。 }}