问题描述
我在数据库中保存的图像路径,像这样:
I have saved an image path in database like so:
C:\Users\3embed\Documents\Visual Studio 2010\Projects\HeritageWeb\HeritageWeb\Images\startbutton.png
我要显示的图像缩略图。现在,我使用这个code:
I want to display the image as thumbnail. Right now I'm using this code:
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="7%" HeaderText="Icon">
<ItemTemplate>
<asp:Image ID="ProfImage" ImageUrl='<%#Eval("Thumbnail","/Images/{0}")%>' runat="server" Width="30px" Height="30px"></asp:Image>
</ItemTemplate>
</asp:TemplateField>
和它给我的整个路径。我只需要startbutton.png。但是,我需要整个路径存储在数据库中,因为我需要它别的地方。
And it's giving me the entire path. I just need startbutton.png. However, I need to store the entire path in the database since I need it somewhere else to.
推荐答案
这是一个有点乱,但尝试更换以下...
It's a bit messy, but try replacing the following...
<%#Eval("Thumbnail","/Images/{0}")%>
使用(未经测试的和更新)...
With (untested and updated)...
&LT;%#的eval(System.IO.Path.GetFileName(的Container.DataItem [缩略图])/图片/ {0})%> 行使>
&LT;%#的String.Format(/图像/ {0},System.IO.Path.GetFileName(EVAL(缩略图)))%>
<%#string.Format("/Images/{0}", System.IO.Path.GetFileName(Eval("Thumbnail")))%>
这篇关于检索图片的ImagePath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!