Hi all
I have a Databasetable with images in it.
Now I want to show those images in a GridTemplateColumn.
I want to show them directly from database, without first storing the pics on disk.
Is this possible? And how?
The code so far looks like this:
<telerik:GridTemplateColumn UniqueName="ImageColumn"> | |
<ItemTemplate> | |
<img id="PlantImage" src='<%# Eval("Image") %>.jpg' alt=""/> | |
</ItemTemplate> | |
<HeaderStyle Width="100px" /> | |
<ItemStyle Width="240px" /> | |
</telerik:GridTemplateColumn> |
But the images wont show up in the Grid.
I'm just stuck.
Thanks for your help.
Joffrey
FYI, this is the code I use to upload the images into the database. They are uploaded with radUpload. Code is mostly from a Telerik KB article.
protected void btnUpload_Click(object sender, EventArgs e) | |
{ | |
mediaTypeTable = mediaType.GetAllMediaTypes(); | |
foreach (UploadedFile file in ruplMedia.UploadedFiles) | |
{ | |
string extension = file.GetExtension().Remove(0,1); | |
string imageType = file.ContentType; | |
string name = file.GetNameWithoutExtension(); | |
//Set the mediaTypeId | |
int mediaTypeId = 0; | |
foreach (DataRow row in mediaTypeTable.Rows) | |
{ | |
if (extension.Equals(row["Extension"].ToString())) | |
{ | |
mediaTypeId = Convert.ToInt32(row["MediaTypeId"]); | |
break; | |
} | |
} | |
//ImageData | |
byte[] binaryImageData = new byte[file.InputStream.Length]; | |
file.InputStream.Read(binaryImageData, 0, Convert.ToInt32(file.InputStream.Length)); | |
media.Insert(Convert.ToInt32(rcbPlant.SelectedValue), mediaTypeId, name, name, binaryImageData); | |
} | |
} |