Getting the List Title in the Widget Template
How do I get the list title to showup in a list template
...not the title of each list item, but the list itself
Hi Steve,
Can you please let us know which template are you using so that we can give you more specific details? In general you can create a custom template and bind to the ItemDataBound event of the RadListView. In the event check if e.Item is RadListDataItem, if it is cast it to RadListDataItem and get the list object by casting the DataItem property of the RadListDataItem object to ListItem. From there on you can get the Parent and its Title property.
All the best,
Radoslav Georgiev
the Telerik team
Hey Radoslav,
I guess I mean ANY of the widget templates in the backend, but lets go with Simple List Content only
So the desired look is
LIST NAME
- listitem1 content
- listitem2 content
- listitem3 content
I tried adding an Eval to the Layout template, but it borked the template
<%@ Control Language="C#" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<
telerik:RadListView
id
=
"listsControl"
runat
=
"server"
ItemPlaceholderId
=
"ListContainer"
EnableEmbeddedSkins
=
"false"
EnableEmbeddedBaseStylesheet
=
"false"
>
<
LayoutTemplate
>
<
div
class
=
"sfsimpleListWrp"
>
<
asp:PlaceHolder
id
=
"ListContainer"
runat
=
"server"
/>
</
div
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
telerik:RadListView
ID
=
"listItemsControl"
runat
=
"server"
ItemPlaceholderID
=
"ItemsContainer"
EnableEmbeddedSkins
=
"false"
EnableEmbeddedBaseStylesheet
=
"false"
>
<
LayoutTemplate
>
<
ul
class
=
"sflistList"
>
<
asp:PlaceHolder
ID
=
"ItemsContainer"
runat
=
"server"
/>
</
ul
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
li
class
=
"sflistListItem"
>
<
sitefinity:HtmlField
runat
=
"server"
DisplayMode
=
"Read"
Value='<%# Eval("Content")%>' />
</
li
>
<
sf:ContentBrowseAndEditToolbar
ID
=
"BrowseAndEditToolbar"
runat
=
"server"
Mode
=
"Edit,Delete,Unpublish"
></
sf:ContentBrowseAndEditToolbar
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
ItemTemplate
>
</
telerik:RadListView
>
Hello Steve,
It seems that you are using an older template. The new ones have the title already. Take a look at the markup. There are 2 nested RadListView controls. The first one displays the List, the second one its items. So if you put the eval right before the second list view you will see the title:
<%@ Control Language="C#" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<
telerik:RadListView
id
=
"listsControl"
runat
=
"server"
ItemPlaceholderId
=
"ListContainer"
EnableEmbeddedSkins
=
"false"
EnableEmbeddedBaseStylesheet
=
"false"
>
<
LayoutTemplate
>
<
div
class
=
"sfsimpleListWrp"
>
<
asp:PlaceHolder
id
=
"ListContainer"
runat
=
"server"
/>
</
div
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
h2
class
=
"sflistTitle"
>
<
asp:Literal
runat
=
"server"
Text='<%# Eval("Title") %>' />
</
h2
>
<
telerik:RadListView
ID
=
"listItemsControl"
runat
=
"server"
ItemPlaceholderID
=
"ItemsContainer"
EnableEmbeddedSkins
=
"false"
EnableEmbeddedBaseStylesheet
=
"false"
>
<
LayoutTemplate
>
<
ul
class
=
"sflistList"
>
<
asp:PlaceHolder
ID
=
"ItemsContainer"
runat
=
"server"
/>
</
ul
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
li
class
=
"sflistListItem"
>
<
asp:Literal
runat
=
"server"
Text='<%# Eval("Title") %>' />
<
sf:ContentBrowseAndEditToolbar
ID
=
"BrowseAndEditToolbar"
runat
=
"server"
Mode
=
"Edit,Delete,Unpublish"
></
sf:ContentBrowseAndEditToolbar
>
</
li
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
ItemTemplate
>
</
telerik:RadListView
>
Ok perfect thanks...hey let me ask you this though
How will we know templates have updates that need to be applied for each update?
Hi Steve,
You can check the changes with win merge and compare your version the files with the latest ones from the archive of control templates which comes with the SDK.
Greetings,
Radoslav Georgiev
the Telerik team