This is a migrated thread and some comments may be shown as answers.

Hiding RadDataPager when there is only one page

2 Answers 255 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Carl
Top achievements
Rank 1
Carl asked on 31 Mar 2010, 11:49 AM
Hello there,

I have a RadListView displaying data in pages of 4 using the RadDataPager:
              <telerik:RadDataPager ID="UnlocatedCasesPager"  
                                                      runat="server"  
                                                      PagedControlID="UnlocatedCasesListView"  
                                                      PageSize="4"
                                    <Fields> 
                                        <telerik:RadDataPagerButtonField FieldType="FirstPrev" /> 
                                        <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="3" /> 
                                        <telerik:RadDataPagerButtonField FieldType="NextLast" /> 
                                    </Fields> 
                                </telerik:RadDataPager> 

I cannot work out how to hide the pager when there are 4 or less items being displayed in my list view. I have tried using the FindControl method of the ListView to get hold of the pager and hide it if necessary in various places (OnDataBound event and when I actually assign the datasource of the ListView) but that always returns null. The pager is contained in the <LayoutTemplate>.

Thanks very much, Carl

2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 31 Mar 2010, 01:43 PM
Hello Carl,

You can use the following binding expression when RadDataPager is placed inside RadListView to hide it when total page count is 1:
<telerik:RadDataPager ID="RadDataPager1" runat="server" 
  Visible='<%# Container.PageCount != 1%>'>

All the best,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Daryl
Top achievements
Rank 1
answered on 29 Feb 2012, 01:07 AM
Or if the RadDataPager is NOT inside the ListView, you can add code like this to the OnNeedDataSource event:
protected void OnNeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
{
  //Bind data
  ...
 
  //Hide the pager if we only have one page
  if (myData.Count <= myRadDataPager.PageSize)
      myRadDataPager.Visible = false;
  else
      myRadDataPager.Visible = true;
}
Tags
ListView
Asked by
Carl
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Daryl
Top achievements
Rank 1
Share this question
or