I have saved an image path in database like so:
C:\Users\3embed\Documents\Visual Studio 2010\Projects\HeritageWeb\HeritageWeb\Images\startbutton.png
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>
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…
With (untested and updated)…
<%#Eval(System.IO.Path.GetFileName(Container.DataItem[“Thumbnail”]),”/Images/{0}”)%><%#string.Format(“/Images/{0}”, System.IO.Path.GetFileName(Eval(“Thumbnail”)))%>