Try our conversational search powered by Generative AI!

Image Gallery - SearchDataSource



I have created a gallery page type and a Image page type. The gallery type contains many image types.

I have successfully rendered all relevant information on the gallery page except the image itself. I have the url to the image page and the acual source to the picture. In my mind I want to use a href and a img to get this working, but how do I combinate episerver:properties and asp:Image?

 I have a SearchDataSource and a DataList to render my information.

And I want something like this inside the datalist:

<img id="aImage" src="" runat="server" / >


But how do I add the source to the img from a episerver:property?






Jan 29, 2009 15:32

not sure of what you mean but you can ad the url to an image from codebehind via CurrentPage["propertyname.."].linkurl have a look in our SDK at for our build in properties and how they work.


You could use front end as well with somthing like this  <%#Container.CurrentPage["ImageLink"].LinkURL%>);


Edited, Jan 29, 2009 17:11


This did the trick:


        <asp:DataList ID="datalist1" DataSourceID="srcDS" runat="server">
                <table border="0">
                    <a href=' <%# ((EPiServer.Core.PageData)Container.DataItem).LinkURL %>'>
                    <asp:Image ImageUrl='<%# ((EPiServer.Core.PageData)Container.DataItem).Property["Image"] %>' Width="90" Height="100" ID="image" runat="server" />


I don't know why, but when I added <%# Container... as you suggested Eric I received the following message:


'System.Web.UI.WebControls.DataListItem' does not contain a definition for 'CurrentPage'


Does it mean that I can't use the CurrentPage in a datalist?

Jan 30, 2009 8:46

Yes exactly you are not able to use currenpage object in a list like listview or datalist. They have something called DataItem instead and you will have to cast that object to a EPiserver PageData object instead, just like you did! Laughing Sorry for the missunderstanding..

 If i where you i would look into using listview instead of datalist beacause you are able to design the html much more in the listviewcontrol.... maybe you already know this but just in case..


Best Regards


Jan 30, 2009 9:38

I understand, thanks.

 I have only read about the ListView, it is a .net 3.5 controll right?

I will take a look at it. It seems to fit my solution in a good way.

Thanks again, /Magnus

Jan 30, 2009 10:39

Yes it is new in 3.5. We are using it a lot on our pages for exampel on this forum and also in our new relate+-package. But a sugestion if your about to work with paging is to actually create your own datapager instead of using the one that comes with listview or at least tweak a little bit.

Here are some pages about listview:



Jan 30, 2009 11:29
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.