任何人都可以指导我如何在asp.net的gridview上显示图像? 我有从数据库获取的图像路径,例如:D:\ Picture \ photo.jpg
我试过这个,但它在图像框中没有显示。 我的前端代码:
<Columns>
<asp:BoundColumn DataField="id" HeaderText="Email ID" Visible="False">
<HeaderStyle />
</asp:BoundColumn>
<asp:BoundColumn DataField="photo_url" HeaderText="Photo" Visible="false">
</asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Image ID="Image1" Height = "100" Width = "100" runat="server" DataImageUrlField = '<%# Eval("photo_url") %>' /> >>>>>>>>display image on this part
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="post_body" HeaderText="Post"></asp:BoundColumn>
<asp:BoundColumn DataField="post_id" HeaderText="Comment/Post ID" Visible="False">
<HeaderStyle Width="50px" />
</asp:BoundColumn>
</Columns>
答案 0 :(得分:3)
替换为这个:
<asp:Image ID="Image1" Height = "100" Width = "100" runat="server" ImageUrl='<%# ResolveUrl(Eval("photo_url").ToString()) %>' />