PagedDatasource for gridview paging

I use PagedDataSource for custom gridview paging. Here is the code:

PagedDataSource dataSource = new PagedDataSource(); int virtualRowCount = Convert.ToInt32(dataset.Tables[1].Rows[0]["TotalRows"]); dataSource.AllowCustomPaging = true; dataSource.PageSize = 15; dataSource.VirtualCount = virtualRowCount; dataSource.DataSource = dataset.Tables[0].DefaultView; gvTaxPayerLoginDetail.DataSource = dataSource; gvTaxPayerLoginDetail.DataBind(); 

I return "totals" from my stored procedure (which is set in virtualRowCount) and the actual rows in tables[0] of the data set. I get results, but my pager is gone. The pager is no longer displayed. How can I show gridview to get value from PagedDataSource?

Work with ASP.Net 4

+6
source share
2 answers

ASP.NET Version 2.0+

This post here http://www.codewrecks.com/blog/index.php/2008/02/09/aspnet-20-gridview-custom-sorting-with-pageddatasource/ extends the standard GridView and provides plumbing code to achieve PagedDataSource integration .

ASP.NET Version 4.5

Set the AllowPaging attribute and AllowCustomPaging attribute in the GridView, as well as the page data source property?

 PagedDataSource dataSource = new PagedDataSource(); int virtualRowCount = Convert.ToInt32(dataset.Tables[1].Rows[0]["TotalRows"]); dataSource.AllowCustomPaging = true; dataSource.PageSize = 15; dataSource.VirtualCount = virtualRowCount; dataSource.DataSource = dataset.Tables[0].DefaultView; gvTaxPayerLoginDetail.AllowPaging = true; // See this line here gvTaxPayerLoginDetail.AllowCustomPaging = true; // and this line here gvTaxPayerLoginDetail.DataSource = dataSource; gvTaxPayerLoginDetail.DataBind(); 

Additionally this post can also help http://www.byteblocks.com/post/2012/03/20/Use-Custom-Paging-in-Grid-View.aspx

+3
source
 PagedDataSource dataSource = new PagedDataSource(); int virtualRowCount = Convert.ToInt32(dataset.Tables[1].Rows[0]["TotalRows"]); dataSource.DataSource = dataset.Tables[0].DefaultView; dataSource.AllowCustomPaging = true; dataSource.PageSize = 15; dataSource.VirtualCount = virtualRowCount; dataSource.CurrentPageIndex =0; gvTaxPayerLoginDetail.DataSource = dataSource; gvTaxPayerLoginDetail.AllowPaging=True; gvTaxPayerLoginDetail.DataBind(); 
+1
source

Source: https://habr.com/ru/post/895564/


All Articles