Unable to Add ListItems declaratively in Template for Simple

Posted by Community Admin on 04-Aug-2018 08:30

Unable to Add ListItems declaratively in Template for SimpleView-based control

All Replies

Posted by Community Admin on 02-Mar-2012 00:00

We've created a custom control that inherits from SimpleView, and implemented its required methods and properties (InitializeControls and LayoutTemplateName). This is a task we've done many times. Our process more or less resembles the tutorial for the NewsRotator control provided here.

As usual, we've created an embedded ascx template control in our assembly. The template contains a standard ASP.NET BulletedList control that contains a few ListeItem elements added declaratively. Strangely, when the control is rendered, the ListItem elements are always empty.

We've tried adding a few different ASP.NET controls that hold ListItem controls such as DropdownList and they too render with no list items.

However Trying a RadComboBox with items declaritavely added, however, works as expected.

For example, if we make our template look like the code below, the item in the combobox shows up, but the item in the BulletedList control does not!

<%@ Control Language="C#" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<asp:BulletedList runat="server">
    <asp:ListItem  Text="TestItem" Value="TestItem" />
</asp:BulletedList>
 
<sf:RadComboBox runat="server ">
    <Items>
        <sf:RadComboBoxItem Text="TestItem"  Value="TestItem"/>
    </Items>
</sf:RadCombobox>

Is this by design? Are you not allowed to declare ListItems in templates for SimpleView-based controls?

Thanks!

Posted by Community Admin on 07-Mar-2012 00:00

Hi,

 Thank you for contacting us.

The declaratively entered items will not render, if they are bound to a data source:

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
 
<asp:BulletedList ID="BulletedList1" runat="server" DataSourceID="SiteMapDataSource1"> </asp:BulletedList>
This is by design for the standard controls(checkbox list, dropdown, etc) that doesn`t have item template as the RadCombobox

Greetings,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 07-Mar-2012 00:00

I don't quite understand your answer. As in the example we put in this post, we are not binding to a datasource at all. We want to add the list items declaratively, which is standard functionality of all these controls.

So am I correct then in saying that in Sitefinity there is no way of declaratively adding items to a BulletedList control in a control template?

Posted by Community Admin on 12-Mar-2012 00:00

Hello,

 Yes I found no way to fore it to render the items.

Kind regards,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed