More in this section

Forums / Developing with Sitefinity / Unable to Add ListItems declaratively in Template for SimpleView-based control

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

4 posts, 0 answered
  1. OakTree Digital
    OakTree Digital avatar
    27 posts
    Registered:
    06 Sep 2012
    02 Mar 2012
    Link to this post
    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!
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    07 Mar 2012
    Link to this post
    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
  3. OakTree Digital
    OakTree Digital avatar
    27 posts
    Registered:
    06 Sep 2012
    07 Mar 2012
    Link to this post
    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?
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    12 Mar 2012
    Link to this post
    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
4 posts, 0 answered