In asp.net you have to take handler to display binary image :
Step 1: Add a handle in your website and write this code in ProcessRequest:
public void ProcessRequest (HttpContext context)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
// Create SQL Command
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Select pname,images from Photos where id =@id";
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = con;
SqlParameter ImageID = new SqlParameter("@id", System.Data.SqlDbType.Int);
ImageID.Value = context.Request.QueryString["id"];
cmd.Parameters.Add(ImageID);
con.Open();
SqlDataReader dReader = cmd.ExecuteReader();
dReader.Read();
context.Response.BinaryWrite((byte[])dReader["images"]);
dReader.Close();
con.Close();
}
Step 2: Add a Image Control in ItemTemplate:
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# "Handler.ashx?id=" + Eval("id")%>'/>
</ItemTemplate>
//display image from the database using handler
Image2.ImageUrl = "Handler.ashx?id=2";