dynamicContentListView_ItemDataBound
Hi,
I'm building a carousel using a custom module and ascx, in my code I need to build up some HTML to act as the pager for the carousel so i have this.
int
pagerIndex = 0;
protected
void
dynamicContentListView_ItemDataBound(
object
sender, Telerik.Web.UI.RadListViewItemEventArgs e)
RadListViewDataItem item = (RadListViewDataItem)e.Item;
DynamicContent dataItem = item.DataItem
as
DynamicContent;
if
(e.Item.ItemType == RadListViewItemType.DataItem || e.Item.ItemType == RadListViewItemType.AlternatingItem)
........
// Build pager
PagerLinks.Controls.Add(
new
LiteralControl(
string
.Format(
"<a data-slide-index=\"0\">1</a>"
, pagerIndex, dataItem.GetValue(
"Title"
).ToString())));
pagerIndex++;
For some reason though I am getting double the amount of links added to PagerLinks, I have 3 items but it outputs this, any idea why?
<
a
data-slide-index
=
"0"
>Peace of mind</
a
>
<
a
data-slide-index
=
"1"
>Advice</
a
>
<
a
data-slide-index
=
"2"
>Lorem ipsum</
a
>
<
a
data-slide-index
=
"3"
>Peace of mind</
a
>
<
a
data-slide-index
=
"4"
>Advice</
a
>
<
a
data-slide-index
=
"5"
>Lorem ipsum</
a
>
Hi David,
Are you using the API to get the Dynamic Content Items from the CMS? You probably have to filter that result to only get back the 'Live' items, as where it by default would return both the 'Live' and 'Master' items.
Kind regards,
Daniel
The way i'm doing it is
There are only 3 items in total, sitefinity seems to be calling the itemdatabound method twice for each item
The actual RadListView displaying the items shows 3 items correctly
Unless you really need to test for normal vs alternating try using this check and see if that helps.
if
(e.Item
is
RadListViewItem)
Also, how are you setting up the event for ItemDataBound?