Unable to Add ListItems declaratively in Template for SimpleView-based control
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
>
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
>
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?
Hello,
Yes I found no way to fore it to render the items.
Kind regards,