ASPX templates
Version 5.x > ASPX templates > Nested CMSRepeaters View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
adam-syndicut - 10/13/2010 4:22:37 AM
   
Nested CMSRepeaters
I have nested cmsrepeaters


<cms:CMSRepeater ID="Homepage" runat="server" Path="/%" ClassNames="CriticalCare.ArticleType" OrderBy="NodeOrder" OnItemDataBound="CategoryRepeater_ItemDataBound">
<ItemTemplate>
<cms:CMSRepeater ID="ArticleTypes" runat="server">
<HeaderTemplate>
<div class="feature-box">
<b><asp:Label ID="Title" runat="server"></asp:Label></b>
<p><asp:Label ID="Description" runat="server"></asp:Label></p>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li><asp:HyperLink ID="ArticleLink" runat="server" ></asp:HyperLink></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</div>
</FooterTemplate>
</cms:CMSRepeater>
</ItemTemplate>
</cms:CMSRepeater>


The backend code is

 protected void CategoryRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
DataRowView dr = item.DataItem as DataRowView;
if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
{
CMSRepeater inner = ((CMSRepeater)item.FindControl("ArticleTypes"));

inner.ClassNames = dr["Doctype"].ToString();
inner.Path = "/%";
inner.TopN = 5;
inner.OrderBy = "Date DESC";
inner.DataBind();
inner.ReloadData(true);

if (inner != null)
{
inner.ItemDataBound += new RepeaterItemEventHandler(this.CategoryRepeaterInner_ItemDataBound);
}

}
}

void CategoryRepeaterInner_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
DataRowView dr = item.DataItem as DataRowView;
if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
{
HyperLink ArticleLink = ((HyperLink)item.FindControl("ArticleLink")) as HyperLink;

ArticleLink.Text = dr["Title"].ToString();
ArticleLink.NavigateUrl = Functions.GetUrl(dr["NodeAliasPath"]);
}
}



its firing the first repeater and and finding the nested repeater in the itemdatabound and applies values to the properties but they do not seem to fire.

i have also tried on the front end of the nested repeater ClassNames='<%# Eval("Doctype")%>'
to get it to pull back that doctype

any ideas



User avatar
Certified Developer v7
Certified  Developer v7
adam-syndicut - 10/14/2010 3:32:53 AM
   
RE:Nested CMSRepeaters
anyone got any suggestions??

User avatar
Certified Developer v7
Certified  Developer v7
luke-syndicut - 10/15/2010 11:18:06 AM
   
RE:Nested CMSRepeaters
gave up doing it kentico way and did it standard .net way. IF ANYONE COMES UP WITH A PURE KENTICO WAY OF DOING THIS LET ME KNOW

 <asp:Repeater ID="Homepage" runat="server" OnItemDataBound="CategoryRepeater_ItemDataBound">
<ItemTemplate>
<asp:Repeater ID="ArticleTypes" runat="server" >
<HeaderTemplate>
<div class="feature-box">
<b><asp:Label ID="Title" runat="server"></asp:Label></b>
<p><asp:Label ID="Description" runat="server"></asp:Label></p>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li><asp:HyperLink ID="ArticleLink" runat="server" ></asp:HyperLink></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</div>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>


 protected void CategoryRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;

if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
{
DataRowView dr = item.DataItem as DataRowView;
Repeater inner = ((Repeater)item.FindControl("ArticleTypes"));

if (inner != null)
{
DataSet ds = TreeHelper.SelectNodes("/%", false, dr["Doctype"].ToString(), null, "Date DESC");
inner.ItemDataBound += new RepeaterItemEventHandler(this.CategoryRepeaterInner_ItemDataBound);

inner.DataSource = ds;
inner.DataBind();

Label Title = ((Label)inner.Controls[0].Controls[0].FindControl("Title"));
Label Desc = ((Label)inner.Controls[0].Controls[0].FindControl("Description"));

Title.Text = dr["Name"].ToString();
Desc.Text = dr["Description"].ToString();
}
}
}

void CategoryRepeaterInner_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;

if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
{
DataRowView dr = item.DataItem as DataRowView;

if (item.ItemIndex <= 2)
{
HyperLink ArticleLink = ((HyperLink)item.FindControl("ArticleLink")) as HyperLink;

ArticleLink.Text = dr["Title"].ToString();
ArticleLink.NavigateUrl = Functions.GetUrl(dr["NodeAliasPath"]);
}
}
}

User avatar
Member
Member
gstaylor-sfopera - 10/18/2010 6:03:27 PM
   
RE:Nested CMSRepeaters
adam,
I've gotten them to work properly. Check out my thread at http://devnet.kentico.com/Forums/f47/t16669/Nested-Repeater-Showing-All-Docs-Under-Current----.aspx

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/18/2010 3:19:45 AM
   
RE:Nested CMSRepeaters
Hi,

How to use the nested repeater control is described here:
http://devnet.kentico.com/docs/controls/cmsrepeater.htm

The property NestedControlsID should be specified in properties of the main repeater.

If you need to dynamically set properties of a nested control, you have to set its DelayedLoading property to 'True'.

Best regards,
Ivana Tomanickova