Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
385
DataSource Paging
posted

My code is set up to do paging at the DataSource level. Up until now I was using the Microsoft GridView. It supports normal DataSource paging. DataSource paging is very simple. The grid asks for a page of data from the DataSource and then the DataSource calls the relevant method with the number of records it wants. This works in GridView.

However, I can't figure out how to make UltraWebGrid use this functionality. If I load 6000 records using a DataSet, paging occurs automatically in the UltraWebGrid. But if I point the grid to a DataSource where paging is enabled, it only displays one page and doesn't show any page numbers.

I looked in the knowledge base on how to achieve paging but it gave a very long example and talks about how to do the work yourself. I don't want to do this. The work is already being done by the DataSource.

An article says:

Standard paging simply requires that the application responds to the PageIndexChanged event to set the new page number and call DataBind(). UltraWebGrid indexes into the DataSource and finds the correct starting point and loads the grid with the PageSize number of rows.

I am going for standard paging. EnableInternalRowsManagement is false. I am handling the PageIndexChanged event by setting the new page number and calling DataBind(). AllowPaging is true. AllowCustomPaging is false.

I'm pretty sure that what is happening is that when the grid is rendered, it is not calling the GetCount method on the DataSource. Instead it is basing its record count on one page of data which of course will not work because one page is always going to display in one page.

How can I force the grid to base its number of pages on the record count from the DataSource? How can I make the grid use DataSource paging?

Parents
No Data
Reply
  • 19308
    posted

    Not sure which version of the grid you're using, but the grid should be able to take advantage of a pagable datasource such as the ObjectDataSource or LinqDataSource.  A classic DataSet doesn't provide datapaging, so the grid will have to bind to all 6000 rows and page itself.  As soon as you use the ObjectDataSource or LinqDataSource (the only 2 with built in paging support), the grid will leverage those features. 

    If you're using a different datasource, and paging isn't implemented through the standard interface, you can use the InitializeDataSource event to tell the grid how many total rows your binding to, and feed it the appropriate page of data.  In order to do this, you have to upcast the eventargs to DataSourceEventArgs.  I've posted some info related to this on my blog (High Performance DataBinding)

    Hope this helps,

    -Tony

Children
No Data