473,396 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Image Display in gridview

1
I am making a project which is related to classified web site.
I have used a gridview control. In which put some sqltable data.
And i want to show a image which is store in my project folder,
Whenever grid will display with my sqltabel data + image.
I have created specific folder for every user who send the data.

<div>
<table style="vertical-align:middle; height:100%; width:100%">
<tr>
</tr>
<tr>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
<asp:GridView ID="grdImageViewer" runat="server" AllowPaging="True" AutoGenerateColumns="false"
AutoGenerateEditButton="false" CellPadding="4" OnPageIndexChanging ="Page_Load" >
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="Title" DataNavigateUrlFormatString="~/Resume/ResumeDetail.aspx?Title={0}"
DataTextField="Title" HeaderText="Title" />


<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:BoundField DataField="Email" HeaderText="Email" />
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<img alt="Image" src='<%#Eval("grdImage")%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>

</div>

cs. file

public partial class Resume_View : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
bindData();
//BindDataImage();

}

private void bindData()
{
string query = "select Title,Description,Email,ImagePath from ResumePosting";
DataTable table = DBUser.ExecuteQuery(query);

if (table.Rows.Count == 0)
return;

int index = 0;

DataTable dt = new DataTable();

dt.Columns.Add("Title", typeof(string));
dt.Columns.Add("Description", typeof(string));
dt.Columns.Add("Email", typeof(string));
dt.Columns.Add("grdImage", typeof(string));
DataRow dr;
int imageindex;
string [] file = Directory.GetFiles(Server.MapPath("~/Resume/Veeru/") + "\\", "*.jpg");
int imagecount = file.Length;
for (index = 0,imageindex=0; index < table.Rows.Count; index++,imageindex++)
{
dr = dt.NewRow();
dr[0] = table.Rows[index]["Title"].ToString();
dr[1] = table.Rows[index]["Description"].ToString();
dr[2] = table.Rows[index]["Email"].ToString();
dr[3] = ResolveUrl("ThumbnailCreator.aspx?ImageId=" + file[imageindex]);
dt.Rows.Add(dr);
if (imageindex == imagecount-1)
{
imageindex = -1;
}
}
grdImageViewer.DataSource = dt;
grdImageViewer.DataBind();
}

I want to show image related to row which is store in my project forlder.
Feb 16 '08 #1
1 2198
lotus18
866 512MB
I think this should be posted to a proper forum : )
Feb 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tan | last post by:
Hi I am desperate for any help with display image in Gridview I have a gridview contain surname , forename ..... and image. I could not display image as my database store the column image as...
1
by: aabruzzese | last post by:
Hi folks, Been struggling with this little puzzle. I am reading the MemberInfo table for the ClubStarterKit, the table includes the Avatar for the User. I would like to display the Avatar...
3
by: yefei | last post by:
I need to display images in a SQL database using a gridview I search some examples, what they did is very simple add an image field, then set the folowing properties <asp:imagefield...
1
by: NH | last post by:
ANy ideas on how to acheive this? I want to display a dynamically created image when a mouse over occurs on a gridview event. I need some way of creating the image (it will be a small chart type...
18
by: Auto | last post by:
Hello, I would like to know how do display an image into a Gridview (ASP.NET 2.0) taken directly from a DataBase, NOT using an URL, like described in this article: ...
2
by: manmit.walia | last post by:
Hello Fellow Developers, I have a small problem that you might be able to help me with. The method that I am trying to create is the ability to export a GridView and a image to word or excel. I...
0
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
I'm using a GridView to display large search results, and in each row I display a "Select" image button to choose the record. What I've been noticing is that when users search and display the...
3
by: aSoundMind | last post by:
Hello Guys, I am not sure is this a common problem. I can't display image which in a gridview to excel or word. I have not try on pdf or web but surely this annoy me. I tried to google it and...
3
by: Froefel | last post by:
Hi group, I'm looking for some help on how to achieve the following in a gridview control that is based on an ObjectDataSource. The SelectMethod of the datasource returns a list of Customer...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.