Search code examples
asp.netlistviewpaginationdatapager

Showing a DataPager for a ListView only when there are at least 30 records


i ma using am listview and datapager control. in my list view i have specfied to show 30 records once exceed thirty records then paging comes where rest of the resords are shown.

issue: when i have only 5 records even then my paging is shown(previous 1 next) even though the link button are disable of paging . i do not want to shown paging untill i exceed thirty records.

i need to shown the paging only when there is more than specfied recoreeds to be shown in an page i do not want pging option to be shown even if i have 1 or 30 records

any help would be great

thank you


Solution

  • You can hide a NextPreviousPagerField object in a DataPager control by setting the Visible property to false. You can also hide the individual buttons (the first-page, previous-page, next-page, and last-page buttons) by setting the ShowFirstPageButton, ShowPreviousPageButton, ShowNextPageButton, and ShowLastPageButton properties to false.

    MSDN Good luck trying it out ;). It will probably be something like

        if(results < 30) { DataPager1.Visible = false; }