---
title: Using nested controls
related:
  - https://docs.kentico.com/k10/developing-websites/loading-and-displaying-data-on-websites.md
  - https://docs.kentico.com/k10/developing-websites/loading-and-displaying-data-on-websites/writing-transformations/using-hierarchical-transformations.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

Nested controls are controls placed within the item templates or [transformations](https://docs.kentico.com/k10/developing-websites/loading-and-displaying-data-on-websites/writing-transformations.md) used by other controls or [web parts](https://docs.kentico.com/k10/developing-websites/developing-websites-using-the-portal-engine/using-and-configuring-web-parts.md). By nesting listing controls, you can display lists of items inside other lists (in a hierarchical structure).

> **Tip:** **Tip**: The [CMSUniView](https://docs.kentico.com/k10/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers/cmsuniview.md) control allows you to display hierarchical data without using nested controls. The UniView controls have better performance than nested listing controls.

The following CMS controls support nested controls:

- [CMSDataList](https://docs.kentico.com/k10/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers/cmsdatalist.md)
- [CMSRepeater](https://docs.kentico.com/k10/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers/cmsrepeater.md)

These controls have the **NestedControlsID** property, which connects the nested controls to the parent control. The parent control then dynamically provides the correct page **Path** to the nested controls for each item in the list.

You can combine the controls as required. Other controls, such as the [CMSDataGrid](https://docs.kentico.com/k10/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers/cmsdatagrid.md) can be nested inside the CMSRepeater or CMSDatalist, but cannot contain nested controls themselves.

> **Note:** **Note**: If you need to set the properties of a nested control in your code, set the control's **DelayedLoading** property to _True_ in the markup.

## Example - Displaying a nested datalist

This following example demonstrates how to use a _CMSRepeater/CMSDatalist_ combination to display a list of product categories and a preview of products in each category (from the sample Corporate Site):

1. Create a new **Web form** in your web project.
2. Drag the **CMSRepeater** control from the toolbox onto the form.
3. Set the following properties for the control:

   - **Path**: /Products/%
   - **ClassNames**: cms.menuitem
   - **NestedControlsID**: CMSDataListNested
   - **OrderBy**: NodeOrder
4. Add the following code marked by the **CMSRepeater template** comments between the __ tags. The overall code of the CMSRepeater control should look like this:

   ```html

   <asp:ScriptManager ID="manScript" runat="server" ScriptMode="Release" EnableViewState="false" />

   <cms:CMSRepeater ID="CMSRepeater1" runat="server" Path="/Products/%" ClassNames="CMS.MenuItem" NestedControlsID="CMSDataListNested" OrderBy="NodeOrder" >

       <%-- CMSRepeater template ----------------------------------------------------------- --%>

       <ItemTemplate>
           <h1><%# Eval("DocumentName") %></h1>

           <%-- Nested DataList ---------------------------------------------------------------- --%>

           <div class="ProductList" >
               <cms:CMSDataList ID="CMSDataListNested" runat="server" ClassNames="cms.smartphone;cms.laptop;cms.software;cms.ebook;cms.product" TransformationName="CorporateSite.Transformations.ProductList" RepeatColumns="6" />
           </div>

           <%-- Nested DataList ---------------------------------------------------------------- --%>

       </ItemTemplate>

       <%-- CMSRepeater template ----------------------------------------------------------- --%>

   </cms:CMSRepeater>

   ```

   > **Info:** This defines the template used by the CMSRepeater to display items. The template contains a nested CMSDataList control that displays all product types in six columns using a [transformation](https://docs.kentico.com/k10/developing-websites/loading-and-displaying-data-on-websites/writing-transformations.md). The **ID** of the nested DataList is the same as the value of the CMSRepeater's **NestedControlsID** property. Note that the **Path** property of the nested data list is not specified, since the parent CMSRepeater control dynamically supplies the path value.
   >
   > You can alternatively achieve the same result by placing the CMSDataList control into the code of an ASCX transformation (assigned through the **TransformationName** property of the CMSRepeater).
   >
   > The **ScriptManager** control included on the page is required by the _CorporateSite.Transformations.ProductList_ transformation used to display product pages. It is only there to ensure that the web form is functional as a standalone example. Typically, the _ScriptManager_ is included on the website's master page.
5. Save the web form.
6. Right-click the web form in the Solution explorer and select **View in Browser**.

The resulting page displays a hierarchical list of product category headers and the products stored under each category.

> **Note:** **Note**: The following image is from a page that uses the default Corporate Site stylesheet to style the displayed products.

![](https://docs.kentico.com/docsassets/k10/using-nested-controls/image.png)
