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.
How can I make the grid use DataSource paging?
More info on this. 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?
me to need an answer. I am using CSLA business objects to populate the webgrid. when I try the rows.count, it gives count of the rows in the current page, but not the entire count of records associated with the webgrid.
Hello,
Yes, but I think this should be the expected behaviour - the grid returns only the rows that are currently displayed, whereas for the total number of rows in the datasource, we should be querying the datasource directly. I am not 100% sure about CSLA, but for any typical .NET datasource (and I am sure CSLA follows these conventions), you would do something along the lines of:
DataTable dt = new DataTable(); // ... // Fetch Data In DataSource // ... int totalRowsInDataSource = dt.Rows.Count;
Great - thanks for sharing the solution - I am sure many people will find it useful since CSLA is quite popular.
Thanks again.
I found an easy way for CSLA business objects. Use System.Collections
((IList)(e.BusinessObjects)).Count