Q:

Image not showing up from database

I'm using DataList with SqlDataSource which everything is preset. Picture is successful stored into database(Image is stored into Database in byte), in TestQuery the image is viewable and all title and description is showing up in the web page just the image didn't show up.
Picture Here
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource" RepeatColumns="3" RepeatDirection="Horizontal">
    <ItemTemplate>
        <asp:Image ID="Image1" runat="server" Height="200px" ImageUrl='<%# Eval("image") %>' Width="200px" />
        <br />
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("title") %>'></asp:Label>
        &nbsp;<br />
        <asp:Label ID="Label2" runat="server" Text='<%# Eval("desc") %>'></asp:Label>
        <br />
    </ItemTemplate>
</asp:DataList>

<asp:SqlDataSource ID="SqlDataSource" 
                   runat="server" 
                   ConnectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\SnorDB.mdf;
                   Integrated Security=True;
                   MultipleActiveResultSets=True;
                   Application Name="EntityFramework" 
                   ProviderName="System.Data.SqlClient" 
                   SelectCommand="SELECT [image], [title], [desc] FROM [Art]">
</asp:SqlDataSource>

A:

Create Generic Handler
public void ProcessRequest(HttpContext context)
{
    string imageid = context.Request.QueryString["id"].ToString();
    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SnorDB"].ConnectionString);
    connection.Open();
    SqlCommand command = new SqlCommand("select image from [Art] where imageid=" + imageid, connection);
    SqlDataReader dr = command.ExecuteReader();
    dr.Read();
    context.Response.BinaryWrite((Byte[])dr[0]);
    connection.Close();
    context.Response.End();

}

public bool IsReusable
{
    get
    {
        return false;
    }
}

At the display webpage
ImageUrl='<%# "ImageHandler.ashx?id="+ Eval("imageid")

by passing the id to the handler.
Reference: Here

