Paging not working when livepersistance = true?

Posts   
 
    
kdekok
User
Posts: 26
Joined: 07-Apr-2008
# Posted on: 29-Apr-2008 15:40:17   

I got really annoyed today when setting the index returned by a simple FindMatches on the entitycollection to the pagindex of a formview. It kept pointing to another record, that was not even on the master gridview anyway.

Paging was enabled on both the gridview and the datasource.

When i looked into things, i noticed that the entitycollection of the datasource has a count of 18... while my pagesize is 10.... What the !??!

Then i got by this thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7603&HighLight=1

Is this thread telling me that it is true that livepersistance is causing paging not to work on a datasource control?

kdekok
User
Posts: 26
Joined: 07-Apr-2008
# Posted on: 29-Apr-2008 16:32:37   

I'm really about to throw things out of the window here !!

Situation: LLBLGenDataSource (UsersDataSource, EntityCollection = TUserCollection) GridView (DataSourceID='UsersDataSource') FormView (DataSourceID='UsersDataSource')

I have this button in the itemtemplate of the gridview:


<asp:Button ID="DetailsButton" runat="server" CommandName="Details" CssClass="btnblue" Text="Details..." CommandArgument='<%# Eval("UserId") %>'/>

And in the eventhandler:


            int UserID = 0;
            int RowIndex = 0;
            System.Diagnostics.Debug.Print("DS Count: {0}", UsersDataSource.EntityCollection.Count);
            switch (e.CommandName) {

                case  "Details":
                    // The userid should be in the argument
                    int.TryParse(e.CommandArgument.ToString(), out UserID);
                    List<int> found = UsersDataSource.EntityCollection.FindMatches(TUserFields.UserId == UserID);
                    if (found.Count == 1)
                    {
                          RowIndex = found[0];
                    }
                    UserGridView.SelectedIndex = RowIndex;
                    UserDetailsFormView.PageIndex = RowIndex;
                    break;
            }

This works all well when i click on the Details button on on of the rows on the first page of the gridview, but after i changed to the second page, this is what happens:

I click the details button of the first row of the second page The formview is displayed, with the data from the first row from the first page !! This data should not even be in the datasource, since when paging is enabled it should only contain the records for this (second) page. When i click the details button again, the right data is displayed.

I noticed the first time, the usersdatasource.entitycollection.count is 8 (the size of the second page), the second time it is 18 (the total amount of records in the database). What is going on here ?!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 29-Apr-2008 22:43:33   

Paging should work fine whatever livepersistence is set to. Be sure you have paging enabled on the datasource control (by setting the property). If not, it will fetch all rows and the paging happens in the bound control. (which could give the same results, but will of course fetch much more data)

Frans Bouma | Lead developer LLBLGen Pro
kdekok
User
Posts: 26
Joined: 07-Apr-2008
# Posted on: 30-Apr-2008 16:05:07   

Otis, thanx for your answer.

Paging is enabled on the datasource, but still it was fetching all the records.

I found out why though ! flushed

The formview was bound to the same datasource, and i did not understand the formview quite yet... it is fetching all the records ALL THE TIME... no matter what paging etc. is enabled on other bound controls, it's clearly not a good practice to bound the grid to the same datasource as the formview...

I've now used an extra datasource with filter on the selectedvalue of the gridview.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Apr-2008 16:24:18   

Makes sense simple_smile