For retrieving image u should use generic handler file , pass the imageid field to the file and in image control refer the handler file as source.
Refer this code which is to be placed inside the generic handler
public void ProcessRequest(HttpContext context) {
id=Request.QueryString["Id"]
SqlCommand command = new SqlCommand();
try {
command.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings("FileUploadConnectionString").ConnectionString);
command.CommandText = "select * from [Table] where ImageId = @Id";
command.Parameters.Add("@FileId", SqlDbType.UniqueIdentifier).Value = id;
command.Connection.Open();
SqlDataReader reader = command.ExecuteReader();
if (reader.Read()) {
context.Response.Clear();
context.Response.ContentType = reader["ImageType"].ToString();
context.Response.AddHeader("Content-Disposition", string.Format("inline;filename={0};", reader["ImageName"].ToString()));
context.Response.AddHeader("Content-Length", reader["ImageSize"].ToString());
context.Response.BinaryWrite(DirectCast, reader["Image"], Byte());
context.Response.End();
}
}
finally {
command.Dispose();
}