if the image is in server, then you have couple of options
1. map the folder as a virtual directory under your application and then you can refer the image. Then include a TemplateColumn in gridview and in the ItemTemplate write an image tag with src set to the relative path.
2. If you can not make the option one, then you can write a handler that read the file from server and send it to the output stream. In the gridview Item template, you call this handler as the src attribute...
The real voyage of discovery consists not in making new landscapes, but in having new eyes
GaneshAtkale
Member
514 Points
399 Posts
How to display image in gridview column by uploading from folder in asp.net
Apr 23, 2012 04:20 AM|LINK
Hi everybody,
I want to display image in gridview column by uploading from server's folder..
can anybody help...
Thanx in advance
MARK AS ANSWER, if my post helps you...
Thanks & Regards
Ganesh Atkale .
sreejukg
All-Star
27555 Points
4110 Posts
Re: How to display image in gridview column by uploading from folder in asp.net
Apr 23, 2012 04:25 AM|LINK
if the image is in server, then you have couple of options
1. map the folder as a virtual directory under your application and then you can refer the image. Then include a TemplateColumn in gridview and in the ItemTemplate write an image tag with src set to the relative path.
2. If you can not make the option one, then you can write a handler that read the file from server and send it to the output stream. In the gridview Item template, you call this handler as the src attribute...
My Blog
Mandeep Joon
Participant
1570 Points
384 Posts
Re: How to display image in gridview column by uploading from folder in asp.net
Apr 23, 2012 04:46 AM|LINK
Hi,
if your fetching data from sql server to gridevies and one of column have image path then you can use this.
<asp:TemplateField>
<ItemTemplate>
<asp:Image
ID="Image1" runat="server" ImageUrl='<%#"~/logos/"+Eval("logo") %>' /> </ItemTemplate>
</asp:TemplateField>
In this Logos stand for directory and ("logo") stand for the column name in sql server. In code page use your select query.
Mark this as answer if it is usefull.
Mandeep Joon
Blog:- Hightechnology.
Arshad Ashra...
Member
620 Points
149 Posts
Re: How to display image in gridview column by uploading from folder in asp.net
Apr 23, 2012 05:14 AM|LINK
Design Page
<div> <asp:GridView ID="gvImage" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField> <ItemTemplate> <img src='<%# Eval("imageFiles") %>' /></ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div>Code
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) BindGridVeiw(); } private void BindGridVeiw() { DataTable dtImage = new DataTable("ImgTable"); dtImage.Columns.Add("ImageFiles", typeof(string)); DataRow dr; string ImagePath = @"Images/tech2.jpg"; //Your Image Path dr = dtImage.NewRow(); dr[0] = ImagePath; dtImage.Rows.Add(dr); gvImage.DataSource = dtImage; gvImage.DataBind(); }amit.jain
Star
11225 Points
1815 Posts
Re: How to display image in gridview column by uploading from folder in asp.net
Apr 23, 2012 05:21 AM|LINK
refer http://csharpdotnetfreak.blogspot.com/2009/06/images-in-gridview-objectdatasource.html
amiT jaiN
ASP.NET C# VB Articles And Code Examples