Hiding RadDataPager when there is only one page

3 posts, 1 answers
  1. Carl
    Carl avatar
    20 posts
    Member since:
    Nov 2008

    Posted 31 Mar 2010 Link to this post

    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. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 31 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daryl
    Daryl avatar
    1 posts
    Member since:
    Feb 2012

    Posted 28 Feb 2012 Link to this post

    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;
    }
Back to Top