To display an image in gridview (file name of the image is stored in database)

Nithadeepak
Posted by Nithadeepak under ASP.NET category on | Points: 40 | Views : 3487
aspx
<asp:FileUpload ID="fileImage" runat="server"  />

aspx.cs

Code for storing the fileImage.FileName in database goes here...

fileImage.SaveAs(Server.MapPath(".\\images\\" + fileImage.FileName));


Retrieving the image in gridview
<asp:GridView ...>
<Columns>
<asp:TemplateField HeaderText="Image" >
<ItemTemplate >
<asp:Image Height="30" Width="45" ID="img1" runat="server" ImageUrl='<%#Eval("Image","images/{0}") %>' />

</ItemTemplate></asp:TemplateField>
</Columns></asp:GridView>

Comments or Responses

Posted by: Lekhyap on: 5/4/2011 Level:Starter | Status: [Member] | Points: 10
Nice.................
Posted by: Venu_msis on: 5/4/2011 Level:Starter | Status: [Member] | Points: 10
This code won't work if the application runs in multiple Servers.

Login to post response