Winforms Datagrid with server side pagination with custom sql query?

Hi how i can manage datagrid but instead of client side pag use server side pagination? right now im loading a sql table with 50k, i dont like to see all 50k records,i will like to only display lets say 200 records per page. Any tips?

note: i know SQL server have an option in the select query to add a LIMIT and OFFSET i think

thank you


9 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team December 1, 2023 11:30 AM UTC

Hi Alexis Gaitan,

Your requirement to only display 200 records per page and load all records can be achieved by using paging. You can bind the datasource to the SfDataPager and set the PageSize to display the desired number of records per page.

UG Link:Paging in WinForms DataGrid control | Syncfusion

Find the sample demo in the attachment.

Regards,
Vijayarasan S

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Sample_fc007e47.zip


AG Alexis Gaitan December 1, 2023 01:37 PM UTC

So synfusion auto paginate? But it uses client side or server side?



VS Vijayarasan Sivanandham Syncfusion Team December 4, 2023 05:55 PM UTC

Alexis Gaitan,

The PageSize of SfDataPager is set to 200, but it's receiving 50,000 records from the server. Initially, the FirstPage displays the first 200 records. When the next button is clicked, another set of 200 records is displayed. This operation is performed on the client side.



AG Alexis Gaitan December 18, 2023 01:42 PM UTC

it will be always on client side? no way to put server side pagination?



VS Vijayarasan Sivanandham Syncfusion Team December 19, 2023 06:24 PM UTC

Alexis Gaitan,

While a WinForms SfDataGrid typically operates on the client side, you can implement server-side pagination by fetching data from the server as needed. We have prepared the simple sample for achieve your requirement.  Find the sample demo in the attachment.

Note: This setup simulates server-side pagination by fetching data based on the page number and size whenever needed. Adjust the FetchDataFromServer method to retrieve data from your server source and modify the OrderInfo class and SfDataGrid to suit your specific data structure and display requirements.

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: SfDataGridDemo_d4429c9d.zip

Marked as answer

AG Alexis Gaitan replied to Vijayarasan Sivanandham December 19, 2023 10:14 PM UTC

but for faster perfomance what you recommend? client or server side? 



SG Santhosh Govindasamy Syncfusion Team December 20, 2023 05:52 PM UTC

Alexis Gaitan,

The performance of the Datagrid should work properly on both the client side and the server side. Suppose you have a problem(Delay),fetching data from the server; at that time, the performance of the Datagrid will be affect.


Regards,
Santhosh.G



AG Alexis Gaitan December 21, 2023 06:04 PM UTC

So for 50k records is ok to use client side



CM Chidanand Murugaiah Syncfusion Team December 22, 2023 01:27 PM UTC

Hi Alexis Gaitan,


Yes, you can use 50k records in the client side.


Loader.
Up arrow icon