ListView with DataPager not working

后端 未结 7 907
[愿得一人]
[愿得一人] 2021-02-07 05:00

From everything I\'ve read, it seemed that adding paging to a ListView control should be dead simple, but it\'s not working for me. After adding the ListView and DataPager contr

相关标签:
7条回答
  • 2021-02-07 05:48

    Take a look at the ListViewPagedDataSource.

    private ListViewPagedDataSource GetProductsAsPagedDataSource(DataView dv)
    {
    // Limit the results through a PagedDataSource
    ListViewPagedDataSource pagedData = new ListViewPagedDataSource();
    pagedData.DataSource = dv;
    pagedData.MaximumRows = dv.Table.Rows.Count;
    pagedData.TotalRowCount = dpTop.PageSize;
    
    if (Request.QueryString[dpTop.QueryStringField] != null)
      pagedData.StartRowIndex = (Convert.ToInt32(Request.QueryString[dpTop.QueryStringField]) - 1) * dpTop.PageSize;
    else
      pagedData.StartRowIndex = 0;
    
    return pagedData;
    }
    

    Though, I have a problem viewing the last page. The DataPager jumps back to the first page, but the data displayed is the last page.

    0 讨论(0)
提交回复
热议问题