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

Accessing the Elements of Advanced Type Pager

When using the advanced grid pager/slider, you can customize the properties of the buttons or labels inside the pager or the slider pager itself. The following steps describe how to access these controls:

  1. Create a handler for the grid's ItemCreated event.

  2. In the event handler, check if e.Item is an instance of GridPagerItem.

  3. Use the FindControl method of e.Item to locate the controls inside the pager. The following table lists the ID's of the controls in the pager when Mode is "NextPrevAndNumeric":

    ControlTypeID
    "Page Size:" textLabelChangePageSizeLabel
    "Page Size" combo boxRadComboBoxPageSizeComboBox

    Example:

    C#
     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
     {
         if (e.Item is GridPagerItem)
         {
             Label lblPageSize = (Label)e.Item.FindControl("ChangePageSizeLabel");
             lblPageSize.Text = "Number of items:";
         }
     }
    VB
     Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemDataBound()
         If TypeOf e.Item Is GridPagerItem Then
             Dim lblPageSize As Label = DirectCast(e.Item.FindControl("ChangePageSizeLabel"), Label)
             lblPageSize.Text = "Number of items:"
         End If
     End Sub
  4. The following table lists the ID's of the controls in the pager when Mode is "Advanced" or "Slider":

 

ControlTypeID
"Go to page" textLabelGoToPageLabel
"Go to page" inputRadNumericTextBoxGoToPageTextBox
"Go to page" " of " textLabelPageOfLabel
"Go to page" link buttonButtonGoToPageLinkButton
"Change page size" textLabelChangePageSizeLabel
"Change page size" inputRadNumericTextBoxChangePageSizeTextBox
"Change page size" link buttonButtonChangePageSizeLinkButton
Slider pagerRadSliderGridSliderPager
ASP.NET
<telerik:RadGrid
    ID="RadGrid1"
    runat="server"
    Width="95%"
    Skin="Vista"
    AllowSorting="True"
    DataSourceID="SqlDataSource1"
    AllowPaging="True" PageSize="5"
    OnItemCreated="RadGrid1_ItemCreated">
    <PagerStyle Mode="Advanced" />
    <MasterTableView Width="100%" DataSourceID="AccessDataSource1" />
</telerik:RadGrid>		

When setting the PageOfLabel, in order to to display the page count number, you would need to append it to the label text as demonstrated below:

C#
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridPagerItem)
    {
        GridPagerItem item = e.Item as GridPagerItem;
        Label pageOfLabel = e.Item.FindControl("PageOfLabel") as Label;
        pageOfLabel.Text = "OF " + item.Paging.PageCount.ToString();
    }
}

See Also

In this article
See Also
Not finding the help you need?
Contact Support