New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Programmatic Creation

In most scenarios the RadDataPager control is a part of a template inside another control or contains templates itself, so when you need to dynamically define it, you must create it during the Init phase of the page.

Defining a RadDataPager in code-behind

When created on Init, the control should first define its properties and fields, only only then get added to the placeholder control used for it in the page.

If you want to put a RadDataPagerTemplatePageField inside, you should create a class implementing the ITemplate interface and assign it as a PagerTemplate of the field.

Here follows an example of a programmatically created RadDataPager inside a RadListView. The control is defined in the LayoutTemplate of the listview and declares a template field itself.

ASPNET
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Customers]" />

See Also