BasicRepeater

The BasicRepeater control is inherited from the standard ASP.NET Repeater control. It ensures data binding automatically. You can use the common ASP.NET Repeater tags to set up BasicRepeater style and behavior - please see the .NET Framework documentation for details.

 

BasicRepeater can be used with any bindable data source - it doesn't use Kentico CMS database or API.

 

Please note: If you want to display documents from Kentico CMS, please use the CMSRepeater control that provides a more convenient way.

 

Properties

 

Property Name

Description

Sample Value

DataBindByDefault

Indicates whether data binding should be performed by default.

 

HideControlForZeroRows

Hides the control when no data is loaded. Default value is False.

 

ZeroRowsText

Text to be shown when the control is hidden by HideControlForZeroRows.

"No records found."

 

Design

 

The design can be modified in the same way as for the standard Repeater control.

 

Example

 

This example will show you how to read a list of products and display it using the repeater.
 

Create a new Web form.
Drag and drop the BasicRepeater control on the form.
Switch to the Source mode and add the following code inside the BasicRepeater tags:

 

[C#], [VB.NET]

 

<itemtemplate>

<h3>

<%# Eval("ProductName") %>

</h3>

<img src='<%# ResolveUrl("~/CMSPages/GetFile.aspx?guid=" + Eval("ProductPhoto").ToString()) %>' />

</itemtemplate>

 
What you did
 
You have defined a template for one record displayed by the repeater control. The control dynamically replaces the <%# ... %> tags with values of the current record. This is repeated for each record in the datasource.
 

Add the following code at the beginning of the Web form code-behind:
 

[C#]

 

using CMS.CMSHelper;

 

[VB.NET]

 

Imports CMS.CMSHelper

 

What you did

 
You have included namespaces we will use.
 

Add the following code to the Page_Load method:
 

[C#]

 

DataSet ds = TreeHelper.SelectNodes("/%", false, "CMS.Product""""ProductName", -1, true);

this.BasicRepeater1.DataSource = ds;

this.BasicRepeater1.DataBind();

 

[VB.NET]

 

Dim ds As DataSet = TreeHelper.SelectNodes("/%", False, "CMS.Product""""ProductName", -1, True)

BasicRepeater1.DataSource = ds

BasicRepeater1.DataBind()

 

What you did

 
You have added code that reads documents from the database and provides them to the BasicRepeater control.

 

Compile and run the project. You should see a page like this:
 
clip0010