Reputation: 161
have read many article and most of the article suggest httphandler or handler for image binding to gridview from SQL Server.
Is it possible to bind images from database to gridview without httphandler or handler?. If yes than provide me sample code
My table schema: Table Name:- ImageGallery
Column Name DataTypes
Photo image
The above table stored the images in <Binary data>
Upvotes: 2
Views: 853
Reputation: 3750
Instead of storing image as Binary datatype in database, U can try an alternate Solution.
1. Make the column datatype as varchar or nvarchar.
2. Store your image in a seperate folder.
3. Fetch the url for that Image.
4. Save it in the Database.
5. Now in your gridview mention tha column data according to ur wish.
6. During Runtime the URL will refer to the content and the image will
be displayed in your Gridview.
Upvotes: 1
Reputation: 67928
Is it possible? Yes. Is it a good idea? Not at all, and here's why. An HttpHandler
is a way of providing a virtual URL for the image. This allows the browser to handle the GET
requests on its own, in an order that's efficient, and asynchronously. This further means that the initial GET
request isn't burdened down with conceivably MB's of images.
The idea of a website is that it's more efficient to make a lot of smaller requests asynchronously than it is to make one massive request. Why? Because you're already at a disadvantage to provide the user with a good experience when disconnected from the server. Adding insult to that injury by making a massive request that could take minutes, isn't going to add to their joy.
Upvotes: 4