Retrieve DataKeyValue of RadListView on RadDataPager change

Environment

Product Version 2009.3 1103
Product RadListView for ASP.NET AJAX

Description

Question: Can you please post an example on how to retrieve datakeyvalue on the raddatapager change? I have RadListView with RadDataPager. One item per page. On clicking on the next button of the raddatapager I want to grab the value (datakeyvalue).

Steps to Reproduce

You can attach to the OnCommand server event of the RadDataPager to check for the PageCommandName and extract the value of the ListBoxDataItem like this:

var dataKeyValue = (RadListView1.Items[0] as RadListViewDataItem).GetDataKeyValue("CustomerID").ToString();

Here is an example based on the RadListView overview demo:

ASPX

<telerik:RadDataPager RenderMode="Lightweight" ID="RadDataPager1" runat="server" PagedControlID="RadListView1" OnCommand="RadDataPager1_Command"
    PageSize="2" CssClass="pagerStyle">
    <Fields>
        <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
        <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="4"></telerik:RadDataPagerButtonField>
        <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
        <telerik:RadDataPagerPageSizeField PageSizeComboWidth="60" PageSizeText="Page size: "></telerik:RadDataPagerPageSizeField>
        <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"></telerik:RadDataPagerGoToPageField>
    </Fields>
</telerik:RadDataPager>

        protected void RadDataPager1_Command(object sender, RadDataPagerCommandEventArgs e)
        {
            if (e.CommandName == RadDataPager.PageCommandName) {
                var dataKeyValue = (RadListView1.Items[0] as RadListViewDataItem).GetDataKeyValue("CustomerID").ToString();
            }
        }
In this article
Not finding the help you need? Improve this article