Problem modifying list template
I am new to Sitefinity and working on getting a better understanding of the widget templates and how to modify them. I am trying to modify the "Titles only" list template (List items - Simple list) and having problems with a custom field that I added to the list. I added a custom field called "PhoneNumber" of type "Short text". I copied the widget template code to the "Titles only" template mentioned above and created a new template called "Titles and Phone Number". So far so good. My problem and confusion is related to my custom field "PhoneNumber" Below is my customized template. The Eval of PhoneNumber on line 19 does not work and I get a "Error parsing the template" message when I try to use the template. If I change line 19 to reference the "Title" field (or remove it all together), the Eval of PhoneNumber on line 35 works without issue. I'm sure there is something trivial that I just don't understand, but I am confused why there is an issue with the Eval on line 19 and not on line 35. Can someone explain what I am doing wrong ?
Thanks in advance for your help -- Jeff Gaiche
01.
<%@ Control Language="C#" %>
02.
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
03.
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
04.
05.
<
telerik:RadListView
06.
id
=
"listsControl"
07.
runat
=
"server"
08.
ItemPlaceholderId
=
"ListContainer"
09.
EnableEmbeddedSkins
=
"false"
10.
EnableEmbeddedBaseStylesheet
=
"false"
>
11.
<
LayoutTemplate
>
12.
<
div
class
=
"sfsimpleListWrp"
>
13.
<
asp:PlaceHolder
id
=
"ListContainer"
runat
=
"server"
/>
14.
</
div
>
15.
</
LayoutTemplate
>
16.
<
ItemTemplate
>
17.
<
h2
class
=
"sflistTitle"
>
18.
<
asp:Literal
runat
=
"server"
Text='<%# Eval("Title") %>' />
19.
<
asp:Literal
runat
=
"server"
Text='<%# Eval("PhoneNumber") %>' />
20.
</
h2
>
21.
<
telerik:RadListView
22.
ID
=
"listItemsControl"
23.
runat
=
"server"
24.
ItemPlaceholderID
=
"ItemsContainer"
25.
EnableEmbeddedSkins
=
"false"
26.
EnableEmbeddedBaseStylesheet
=
"false"
>
27.
<
LayoutTemplate
>
28.
<
ul
class
=
"sflistList"
>
29.
<
asp:PlaceHolder
ID
=
"ItemsContainer"
runat
=
"server"
/>
30.
</
ul
>
31.
</
LayoutTemplate
>
32.
<
ItemTemplate
>
33.
<
li
class
=
"sflistListItem"
>
34.
<
asp:Literal
runat
=
"server"
Text='<%# Eval("Title") + " " %>' />
35.
<
asp:Literal
runat
=
"server"
Text='<%# Eval("PhoneNumber")%>' />
36.
</
li
>
37.
</
ItemTemplate
>
38.
</
telerik:RadListView
>
39.
</
ItemTemplate
>
40.
</
telerik:RadListView
>
41.
<
asp:PlaceHolder
ID
=
"socialOptionsContainer"
runat
=
"server"
/>
Hi Jeff,
I suppose you are working with either Simple list or Page List as shown below:
Let me try to explain why is this happening:
The template you are working on has 2 RadListView controls - the first one shows a list of all Lists and the second shows the individual items for each list. That's why you can use the PhoneNumber custom field only in the second RadListView - because it knows the data/fields of the list items, whereas the first RadListView knows only about the Lists, nothing about their items. Since the PhoneNumber field is on an Item level - you can use it only in the second RadListView.
I hope this make sense. Please let me know if there is anything I can help you with.
Regards,
Veselin Vasilev
Telerik