API Questions on Kentico API.
Version 5.x > API > How to display on unigrid View modes: 
User avatar
Member
Member
mj-y - 12/24/2012 11:38:27 PM
   
How to display on unigrid
Hi
I have a custom table with an image field ... It's Attribute type is "Text" and it's Field type is "image selection" ... now I want to show it in a unigrid as an image... I used the code below in gridElem_OnExternalDataBound(.....) event :
 case "adimage":
if (parameter != DBNull.Value)
{
string str = " <img alt=\"\" id=\"mjimage\" style=\"padding:2px; width:30px; height:30px; border-color:#999999;\" src=\"<%# GetFileURL(" + parameter.ToString() + ")%>?maxsidesize=120\" />";
return str;
}

but it just shows an empty image in the browser ... I also use "GetImage" but it didn't work too ...

User avatar
Member
Member
mj-y - 12/24/2012 11:41:58 PM
   
RE:How to display image on unigrid
how can I edit the topic and change it to " How to display image on unigrid?"

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/25/2012 10:26:47 AM
   
RE:How to display on unigrid
Hi,

This topic was already covered in this forum thread and you cna use the same idea. You will need to compose the URL using e.g. the "getfile" format of the URL.
So, in the code you will compose the URL like:

<img src=\""~/getfile/" + GUIDcolumnValue + "/whatever.aspx"\" />

Best regards,
Juraj Ondrus

User avatar
Member
Member
mj-y - 12/26/2012 1:11:40 AM
   
RE:How to display on unigrid
Hi jurajo
thx for your reply ... I read that thread and tried your code ... but I didn't get how should I write my code ... I have a field named AdImage that it's "type field" is "image selection" ... what should I replace with "whatever.aspx"?
can u please write the exact code that I should use?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/26/2012 1:40:59 AM
   
RE:How to display on unigrid
Hi,

"whatever.aspx" means really whatever since you can type there what ever you want bacause it is not significant and it is there just to have complete URL. To get the node the GUID part of the URL is used and the "whatever.aspx" is not processed.

Best regards,
Juraj Ondrus