C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Videos


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...


Birthday Greetings
Learn Windows 7: Windows 7 cannot connect to internet - How to fix it   This article explains and discusses the problems related to internet connection in Windows 7 and the the way to solve them.



Resources » Code Snippets » Images »

Retrieve images from database in a gridview


Posted Date: 19 Jun 2009    Resource Type: Code Snippets    Category: Images
Author: Nikhil GaurMember Level: Diamond    
Rating: 1 out of 5Points: 10



This is a sample code to retrieve images from data base in a gridview as to upload images to database.

use fileupload control to upload images and on upload button click retrieve image from fileupload control(named as fulimage)by writing

StreamimgStream = fuImage.PostedFile.InputStream;

and insert it into database along with other parameters.

to retrieve image from database in a gridview use generic handler. place a template in gridview and place itemtemplate in it.now add a image here like this.



and in the ImageHandler.ashx get image id from query string and retrive image from database in a datareader then return that image by this code

context.Response.BinaryWrite((Byte[])dr[0]);

here dr[0] means that image is in first field of the database.

Attachments

  • Retrieve images from database in a gridview (29410-191618-GridviewImage.rar)




  • Responses to the resource: "Retrieve images from database in a gridview"

    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Image  .  Gridview  .  Database  .  Retrieve  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Resize an image's dimensions and Save it as a file in different extension
    Previous Resource: Creating Thumbnail Images in C#
    Return to Resources
    Post New Resource
    Category: Images


    Post resources and earn money!
     
    More Resources



    About Us    Contact Us    Privacy Policy    Terms Of Use