ADO Database ASP.Net

<%@ Page Language="C#" %>
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


    Photo Gallery


    
    

            id="dlstImages"
        DataSourceID="srcImages"
        RepeatColumns="3"
        Runat="server">
        
                    ImageUrl='<%# String.Format("DynamicImage.ashx?id={0}", Eval("Id")) %>'
            Width="250"
            Runat="server" />
            <%# Eval("Description") %>
        

    
            id="frmImage"
        DataSourceID="srcImages"
        DefaultMode="Insert"
        Runat="server">
        
                    id="lblImage"
            Text="Upload Image:"
            AssociatedControlId="upImage"
            Runat="server" />
                    id="upImage"
            FileBytes='<%# Bind("Image") %>'
            Runat="server" />
                    id="lblDescription"
            Text="Description:"
            AssociatedControlID="txtDescription"
            Runat="server" />
                    id="txtDescription"
            Text='<%# Bind("Description") %>'
            TextMode="MultiLine"
            Columns="50"
            Rows="2"
            Runat="server" />
                    id="btnInsert"
            Text="Add Image"
            CommandName="Insert"
            Runat="server" />
        

    
            id="srcImages"
        SelectCommand="SELECT ID,Description FROM Images"
        InsertCommand="INSERT Images (Image,Description) VALUES (@Image,@Description)"
        ConnectionString="<%$ ConnectionStrings:Images %>"
        Runat="server" />
    

    


File: Web.config

  
             connectionString="Data Source=.\SQLEXPRESS;
         AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True;User Instance=True" />
  


File: DynamicImage.ashx
<%@ WebHandler Language="C#" Class="DynamicImage" %>
using System.Data;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
public class DynamicImage : IHttpHandler
{
    public void ProcessRequest (HttpContext context)
    {
        string imageId = context.Request.QueryString["Id"];
        SqlDataSource src = new SqlDataSource();
        src.ConnectionString = WebConfigurationManager.ConnectionStrings ["Images"].ConnectionString;
        src.SelectCommand = "SELECT Image FROM Images WHERE Id=" + imageId;
        DataView view = (DataView)src.Select(DataSourceSelectArguments.Empty);
        context.Response.BinaryWrite( (byte[])view[0]["Image"]);
    }
    public bool IsReusable
    {
        get {
            return false;
        }
    }
}