开发者

image in gridview

开发者 https://www.devze.com 2023-03-06 00:06 出处:网络
HI Im trying to show an image in a gridview, its held on the filesystem and the filename is returned in the datasource query.

HI

Im trying to show an image in a gridview, its held on the filesystem and the filename is returned in the datasource query.

If the fi开发者_开发技巧les are held in C:\TEMP, how would I properly structure the code below?

thanks

<asp:Image ID="Image" runat="server" ImageUrl='<%#"C:\TEMP\" + Eval("ImagePath") %>'


I believe it is along these lines

<asp:Image ID="Image" runat="server" ImageUrl="C:\TEMP\<%= Eval("ImagePath") %>"/>


In this scenario, your ImageUrl value needs to be relative to the root of your web application so if your webapp is in:

c:\iis\MyWebApp

and images are in:

c:\iis\MyWebApp\img the ImageUrl should evaluate to something like ~/img/Img1.jpg

You could store the full path e.g. `~/img/Image1.jpg' in the db or just the filename, in which case you need to add the path to the ImageUrl value either in code-behind or in the markup.

See this article for more information.

Hth.

0

精彩评论

暂无评论...
验证码 换一张
取 消