question

FedericoR-2172 avatar image
0 Votes"
FedericoR-2172 asked YihuiSun-MSFT rolled back

ListView DataPager issue

Hello Everyone,

I am using a Listview and a DataPager. The DataPager is configured like this:

         <asp:DataPager ID="DataPager" PageSize="20" class="btn-group btn-group-sm" runat="server">           
             <Fields>                  
                 <asp:NextPreviousPagerField  PreviousPageText="<" FirstPageText="<<" ShowPreviousPageButton="true"
                     ShowFirstPageButton="true" ShowNextPageButton="false" ShowLastPageButton="false"
                     ButtonCssClass="btn btn-default" RenderNonBreakingSpacesBetweenControls="false" RenderDisabledButtonsAsLabels="false" />
                 <asp:NumericPagerField ButtonType="Link" CurrentPageLabelCssClass="btn btn-default grey-gallery disabled"  RenderNonBreakingSpacesBetweenControls="false"
                     NumericButtonCssClass="btn btn-default" ButtonCount="4" PreviousPageText="..." NextPageText="..." NextPreviousButtonCssClass="btn btn-default" />
                 <asp:NextPreviousPagerField NextPageText=">" LastPageText=">>" ShowNextPageButton="true"
                     ShowLastPageButton="true" ShowPreviousPageButton="false" ShowFirstPageButton="false"
                     ButtonCssClass="btn btn-default" RenderNonBreakingSpacesBetweenControls="false" RenderDisabledButtonsAsLabels="false"/>
             </Fields>
         </asp:DataPager>


Everything works fine but this. If i have 15 pages for example... i see blocks of navigation like this

<< < 1 2 3 4 ...> >>
<< < ... 5 6 7 8 ...> >>
<< < ... 9 10 11 12 ...> >>
<< < ... 13 14 15 > >>

When i clic the "..." button after numer 12, that should load last block of page navigation... it does not. But if I hit the ">" it does load. When debugging, i get the same value for e.StartRowIndex when hitting "..." or ">"

         Private Sub Listado_PagePropertiesChanging(sender As Object, e As PagePropertiesChangingEventArgs) Handles Listado.PagePropertiesChanging
             Try
                 Paginacion.SetPageProperties(e.StartRowIndex, e.MaximumRows, False)
                 DataBindListView()
             Catch ex As Exception
                 Throw
             End Try
         End Sub


So it is very weird, starting to think that it is a control bug. Have anyone deal with this?

dotnet-aspnet-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YihuiSun-MSFT avatar image
0 Votes"
YihuiSun-MSFT answered YihuiSun-MSFT rolled back

Hi @FedericoR-2172,

According to the code you provided, you did not set the PagedControlID. When the PagedControlID is set, the problem you mentioned will not occur.

  1. <asp:DataPager ID="DataPager" PageSize="20" class="btn-group btn-group-sm" runat="server" OnPreRender="Page_Load" PagedControlID="TestListView" >

  2. <asp:ListView ID="TestListView"

Here is an example, you can refer to it.

Page:

xxx.aspx.cs

 Public Partial Class _Default
     Inherits Page
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
         TestListView.DataSource = testdata()
         TestListView.DataBind()
     End Sub
    
     Public Function testdata() As DataTable
         Dim table As DataTable = New DataTable()
         Dim column As DataColumn
         Dim row As DataRow
         table.Columns.Add(New DataColumn With {
             .DataType = Type.[GetType]("System.String"),
             .ColumnName = "TestId"
         })
         table.Columns.Add(New DataColumn With {
             .DataType = Type.[GetType]("System.String"),
             .ColumnName = "TestName"
         })
    
         For i As Integer = 1 To 500 - 1
             row = table.NewRow()
             row("TestId") = i.ToString()
             row("TestName") = "TestName" & i.ToString()
             table.Rows.Add(row)
         Next
    
         Return table
     End Function
 End Class

Result


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
YihuiSun


index.txt (2.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.