News ItemTemplate Index
Hi,
I am trying to define my own template of the news list and I must know what is the last element to give him a diferent style.
I have tried to acomplish this using the folowing code
<telerik:RadListView ID=
"NewsList"
ItemPlaceholderID=
"ItemsContainer"
runat=
"server"
EnableEmbeddedSkins=
"false"
EnableEmbeddedBaseStylesheet=
"false"
>
<LayoutTemplate>
<div class=
"col-second-box-bg"
>
<h3 class=
"bg txt-shadow"
>News</h3>
<ul >
<asp:PlaceHolder ID=
"ItemsContainer"
runat=
"server"
/>
</ul>
</div>
</LayoutTemplate>
<ItemTemplate>
<li class=
'<%# ((ListViewDataItem)Container).DisplayIndex == 1 ? "last" : "" %>'>
<h5 >
<sf:DetailsViewHyperLink ID=
"DetailsViewHyperLink1"
TextDataField=
"Title"
ToolTipDataField=
"Description"
runat=
"server"
/>
</h5> ...
<%# ((ListViewDataItem)Container).DisplayIndex == 1 ? "last" : "" %>
Hi Paulo,
The problem here is that our template parser cannot parse the value you use. Sitefinity uses its own parser for parsing embedded resources. Compared to the ASP.NET parser, this parser has limited capabilities for parsing C# code. In one of the future updates it will be added the option of using the ASP.NET template parser for similar scenario like yours.
The solution requires to remove this code from your .ascx file and then to move it to a custom class that inherits from MasterListView and its InitializeControls method where you will be able to access NewsList from the view container
To register your custom MasterListView,open App_Data/Sitefinity/Configuration/NewsConfig.config and register the new MasterListView.
<contentViewControls>
<contentViewControl definitionName="NewsFrontend">
<views>
<view viewName="NewsFrontendListCustom" ViewType="Telerik.Sitefinity.Samples.Class2, Telerik.Sitefinity.Samples" />
</views>
</contentViewControl>
</contentViewControls>
Finally you have to set the custom MasterListView inside Home > ControlDefinition > Views > NewsFrontendList of the NewsView control
All the best,