Author: Rafael_Soteldo | Posted on: 3/21/2010 3:58:26 PM | Views : 299

Hi there:
I'm trying to show images that come from a sql query into a GridView column, the problem is that the best solution found in the web searches the database twice for each row.
This solution says that we have to first create a handler (ImageHandler.ashx),
It will receive the ID of the row that contains the image, and then query the database with that ID.
Then it will finally perform something like "context.Response.BinaryWrite((byte[])dReader["Photo"]);" (in this case the handler uses a DataReader, I guess we could use another approach)
We also have to declare the image column in the markup as:
<asp:TemplateField HeaderText="Image">
   <ItemTemplate>
      <asp:Image ID="Image1" runat="server"  ImageUrl='<%# "ImageHandler.ashx?ID=" + Eval("ID")%>' /&g ...

Go to the complete details ...