I have been asked to try and populate an image control from a sql server DB. When I have done this before I would use the gridview.
Is this possible as I cant find any examples to look at on-line.
I am using a stored Proc and the sqlDataReader.HasRows I want to add the image to the image ID to display on the page.
Before I have used:
<img src='data:image/jpg;base64,<%# Eval("Photo") != System.DBNull.Value ? Convert.ToBase64String((byte[])Eval("Photo")): string.Empty %>'
alt="Person Image" height="80" width="80" />
I am not sure what I would put If the reader.HasRows
I was thinking ImageID.Something? then ImageID.DataBind();
* EDIT *
if (rdr.Read())
{
byte[] bytes = (byte[])rdr["Photo"];
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
img_Pict.ImageUrl = "data:image/jpg;base64," + base64String;
img_Pict.Visible = true;
}