Monday, February 18, 2008

How to show large table in a data grid with .NET

I think showing large amount of data in a grid is a problem, especially for greenhorns like me. Yesterday I found a way to solve it. It doesn't use TableAdapter.Fill method and direclty shown without loading large amount of data. It will load data partially when you scroll down or filter.
To see how it works, follow this:

I tried GridControl Component of Developer eXpress Components. This GridControl control has ServerMode property.

Using ServerMode:
1. Create a new form (ex: Form1)
2. Add DataSet and typed datatable to it; Recommend you to create it using Add DataSource wizard (ex: DataSet1; CustomersDataTable)
3. Add GridControl to a Form1 (ex: GridControl1)
4. Set GridControl1.ServerMode property to True
5. Add XpServerCollectionSource control (ex: xpServerCollectionSource1)
6. Set DataSet1.CustomerDataTable to ObjectClassInfo property of xpServerCollectionSource1
you can select it from property combobox, shown as WindowsApplication1.DataSet1+CustomerDataTable
7. Select xpServerCollectionSource1 as GridControl1.DataSource
8. type following code to Form1_Load or anywhere before GridControl1 is loaded
XpoDefault.ConnectionString= DevExpress.Xpo.DB.OracleConnectionProvider.GetConnectionString("local", "scott", "tiger");
// in this case i used Oracle 10g

for other DBMS you can use other connection providers included in DevExpress.Xpo.DB package
ServerMode supports manay databases such as Oracle, MSSQL, MySQL, Access ...

You can download evalution version of the component from http://www.devexpress.com/Downloads/

1 comment:

Unknown said...

I can't get to load data in xtragrid, this is empty, never fill.
Can you make a example file to download it?

Thank you.