Scenario
This article illustrates how to use the XPPageSelector component to provide Pager functionally to the XtraGrid control. This functionality is useful when you need to show data in small portions.
Steps
1. Create a new Windows Forms Application.
2. Add DXperience ORM Data Model Wizard to the application and use the Generating Persistent Objects for Existing Data Tables approach to generate persistent objects from an existing database.
3. Add the XPCollection component to a Form and set the ObjectClassInfo property to the generated persistent object type to populate this collection with required objects.
4. Add the XPPageSelector component to the Form and set the Collection property to XPCollection.
5. Add GridControl to the Form and use the XPPageSelector as a data source.
6. Add two Buttons and a Label. These controls will be responsible for page navigation.
7. Handle Button.Click events and create a method, which will update Label text as shown in the Form1.xx file.
Important notes:
Please note that paging is not applicable to the XtraGrid, as the grid requires the entire collection to correctly apply any sorting, grouping or filtering. Therefore, grouping, sorting and filtering will only be applied to the current page when the grid is bound to the XPPageSelector component. We suggest that you use the Server Mode feature instead.
See also:
Tutorial 1 - Your First Data-Aware Application with XPO
How to: Bind an XPCollection to the Grid
Question Comments
Added By: Vikas Gupta 7 at: 11/28/2012 3:24:44 PM
Thanks for the code - but it's not working for me - I have tables with Schema for ex: Business.Files
In the class I am using
namespace ForeSight.Business
{
public class Files : XPLiteObject
{
int fFileID;
[Key(true)]
public int FileID
{
get { return FileID; }
set { SetPropertyValue<int>("FileID", ref fFileID, value); }
}
... and more fields
}
public Files(Session session) : base(session) { }
public Files() : base(Session.DefaultSession) { }
public override void AfterConstruction() { base.AfterConstruction(); }
}
I am setting up the xpoDefault connectionstring by
XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString(@"localhost\sqlexpress", "DatabaseName");
The application runs but
The problem is each time it runs it creates a new table name in the database named dbo.Files (which obviously is empty) thus shows nothing....
I got your example application and created a similar application and verified the code - but found nothing abnormalities...
What am i doing wrong?
let me know if can get you more information thanks
When binding xpPageSelector1 as datasource to grid control it is giving object reference error. Could you attach working project?
Added By: Alexey (DevExpress Support) at: 7/16/2015 3:17:42 AMHello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T267692: When binding xpPageSelector1 as datasource to grid control it is giving object reference error. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.