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 ?!