hi,
how can i dispaly image file like jpg, gif etc. from sql database to gridview or aspx page in asp.net.
thanking u all in advance
anu bajracharya
hi,
how can i dispaly image file like jpg, gif etc. from sql database to gridview or aspx page in asp.net.
thanking u all in advance
anu bajracharya
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Gorgi Markovski5 reputationPosted Apr 9, 2009, 2:46 AM EDT
Ruchi R91 reputationPosted Apr 9, 2009, 3:28 AM EDT
Thanks for ur reply.
Actually i am new user of asp.net .So can u plz tell me how to do all this.Waiting for ur reply.
aru v30 reputationPosted Apr 9, 2009, 4:05 AM EDT
Hi,
Are you storing the Image path in SQL or the Image itself?
Thanks,
Aru
Ruchi R91 reputationPosted Apr 9, 2009, 9:59 PM EDT
Thanks for the reply,
i have stored image itself in the sql database.table for this contains following fields like image_id (int), image_name(varchar), image_data(image), image_contenttype(varchar).Now i need to display image name , image_data, and imagecontentype in a grid view or in aspx file.how can i do this?
waiting for ur reply
Blocked AccountRank #403 · 6.2K reputationPosted Apr 10, 2009, 12:56 AM EDT
Hi
Take the reference of this article, this article will solve your problem.
http://www.aspsnippets.com/post/2009/02/21/Display-Images-from-Database-using-ASPNet.aspx
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Apr 10, 2009, 9:33 AM EDT
Say u have created the following
Now in your code behind get the image Path and display it.
Something like this.
imgEvent2.ImageUrl = dstEvents.Tables["Events"].Rows[intIndex]["evm_txt_EventImagePath"].ToString();
I am using dataset(dstEvents) to fetch the record from table.
Make sure the path contains the image correctly.
Ruchi R91 reputationPosted Apr 15, 2009, 10:44 PM EDT
hi all,
Actually i need to display pictures in gridview in thumbnail size . when user clicks on the thumbnail picture , large sized picture should be displayed.Is it possible to do .If yes then how can i do it.
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Apr 15, 2009, 11:19 PM EDT
Ruchi R91 reputationPosted Apr 16, 2009, 1:38 AM EDT
thanks for ur reply,
can u plz send me c# code to do this...........
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Apr 16, 2009, 2:05 AM EDT
I think, I have already sent you the code concept. Only thing you need to do is giving proper image path for different size of image.
Checkout the following articles to display images in gridview.
1. http://www.devasp.net/net/articles/display/692.html
2. http://www.aspxcode.net/free-asp-net-data-sample-source-code.aspx?Topics=How%20to%20display%20images%20in%20GridView
Rekha SinghRank #1,572 · 1K reputationPosted Dec 28, 2009, 2:05 AM EST
write this code on page load of ur aspx page
//build our query statement
string sqlText = "SELECT PassPicture FROM PassportDetails WHERE empcode = 123 ";
SqlConnection connection = new SqlConnection("Your ConnectionString Here");
SqlCommand command = new SqlCommand(sqlText, connection);
//open the database and get a datareader
connection.Open();
SqlDataReader dr = command.ExecuteReader();
dr.Read();
Response.Clear();
byte[] buffer = (byte[])dr["PassPicture"];
int blen = ((byte[])dr["PassPicture"]).Length;
Response.OutputStream.Write(buffer, 0, blen);
Response.End();
connection.Close();
this code will display the image in ur aspx page