Try our conversational search powered by Generative AI!

Image Gallery - SearchDataSource

Vote:
 

 

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?

/Magnus

 

 

 

 

#27423
Jan 29, 2009 15:32
Vote:
 

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 http://sdk.episerver.com for our build in properties and how they work.

 

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

 

#27428
Edited, Jan 29, 2009 17:11
Vote:
 

 

This did the trick:

 

        <asp:DataList ID="datalist1" DataSourceID="srcDS" runat="server">
            <HeaderTemplate>
                <table border="0">
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <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" />
                    </a>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
               </table>
            </FooterTemplate>
        </asp:DataList>

 

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?

#27433
Jan 30, 2009 8:46
Vote:
 

Yes exactly you are not able to use currenpage object in a asp.net 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

 /Eric 

#27437
Jan 30, 2009 9:38
Vote:
 

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

#27440
Jan 30, 2009 10:39
Vote:
 

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:

  1. http://www.beansoftware.com/ASP.NET-Tutorials/ListView-DataPager.aspx
  2. http://davidhayden.com/blog/dave/archive/2007/11/23/ListViewDataPagerASPNETSearchEngineOptimizationSEO.aspx
  3. http://asp.net

/Eric

#27452
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.