What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 569 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > Can we Store Images in an array ? How this can be done ? ...
.Netlearner

Can we Store Images in an array ? How this can be done ?

Replies: 5 | Posted by: .Netlearner on 6/6/2012 | Category: ASP.NET Forums | Views: 504 | Status: [Member] | Points: 10  


Hello All,
I want to display latest five product images from the database in 5 seperate image control.How this can be implemented ?

For String I have writtern as follows,

   cmd = new SqlCommand("select  TOP 4 ProductName,ProductImage FROM Products ORDER BY ProductId DESC", con);

dr = cmd.ExecuteReader();
while (dr.Read())
{
product[index] = dr["ProductName"].ToString();
index++;
}
dr.Close();

lblproduct1.Text=product[0].toString();
lblproduct2.Text=product[1].toString();


In Similar way i want to display images also.kindly Guide me


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Vuyiswamb
Vuyiswamb  
Posted on: 6/6/2012 3:18:52 PM
Level: NotApplicable | Status: [Member] [MVP] [Administrator] | Points: 25

an image is stored in a Bytes Field, so you need to retrieve the image and pass it to the Byte Array variable and directly bind the image control from a datasource property and it will show your images from the DB

Thank you for posting at Dotnetfunda
[Administrator]

.Netlearner, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

.Netlearner
.Netlearner  
Posted on: 6/7/2012 6:25:20 AM
Level: Starter | Status: [Member] | Points: 25

I didnt get it Can u pls help me with the example code ?

Am having 5 image controls and many images on the database.i want to display only the lastly added five images to the control how this can be done ?

.Netlearner, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ajay.Kalol
Ajay.Kalol  
Posted on: 6/7/2012 7:53:30 AM
Level: Starter | Status: [Member] | Points: 25

Don't store whole Image in DB, just store its Name and at runtime retrieve it from its Path by its Name;

Use Databind control like repeater for this,Don't use separate 5 Image control.
OR Fast way if you want to Just Display then Use dynamic created HTML to display.
set image Path in Databound event if you use databind control.

for your lastly added 5 image query :
SELECT TOP 5 imgID,imgName from Table Order By InsertionDate desc



http://ajaypatelfromsanthal.blogspot.in

.Netlearner, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

CGN007
CGN007  
Posted on: 6/7/2012 8:37:13 AM
Level: Silver | Status: [Member] | Points: 25

Hope you see this...
http://www.dotnetfunda.com/articles/article1084-saving-images-into-the-database-in-aspnet-and-displaying-to-the-gridview.aspx

.Netlearner, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

CGN007
CGN007  
Posted on: 6/23/2012 10:05:58 AM
Level: Silver | Status: [Member] | Points: 25

Mark as Answer if its helpful to you,that motivates...

.Netlearner, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 12:36:17 PM