Try with Handler.
See this,
.aspx :
<asp:image id="Image1" runat="server" imageurl="<%# "ImageHandler.ashx?ImageId=" + Eval("ImgID") %>" cssclass="Image" />
.aspx.cs :
public class ImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
SqlConnection con = new SqlConnection(@"Data Source=rohit\sqlexpress;Initial Catalog=Games;Integrated Security=True");
try
{
con.Open();
string ImageId = context.Request.QueryString["ImageId"];
SqlCommand cmd = new SqlCommand("select AlbumArt from GamesList where ImgID = " + ImageId, con);
cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
byte[] photu = dr[0] as byte[];
context.Response.BinaryWrite(photu);
context.Response.End();
}
}
catch (Exception ex)
{
ex.ToString();
context.Response.Write(ex.ToString());
}
finally
{
con.Close();
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
-KR