We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load pages in OnDemand using async await?

Platform: Silverlight |
Control: SfDataGrid |
.NET Framework: 4.5
Tags: paging

SfDataPager allows you to load the data for the current page, in OnDemandPaging, at runtime. You can enable OnDemandPaging by setting SfDataPager.UseOnDemandPaging to True. The data for the current page needs to be loaded in SfDataPager.OnDemandLoading event via SfDataPager.LoadDynamicItems method. When using OnDemandPaging, you may have to read data from some external server sometimes, it takes some time to read the data. In this case, you can delay the loading in SfDataPager.OnDemandLoading event by using async and await.

The following section shows you how to load the data with some delay in OnDemandPaging using async and await.

Here, SfDataPager and SfDataGrid are defined and SfDataGrid.ItemsSource is bound to SfDataPager.PagedSource. Also OnDemandLoading event is hooked for SfDataPager.



The OnDemandLoading event is triggered when the pager moves to the corresponding page. The OnDemandLoading event contains the following event arguments:

  • StartIndex: Corresponding page start index.
  • PageSize: Number of items to be loaded for that page.

Here dataPager_OnDemandLoading is defined with async keyword to await data loading. Inside dataPager_OnDemandLoading, GetEmployeesDetailsListAync method is called with await keyword and the execution is stopped here until GetEmployeesDetailsListAync returns the data. GetEmployeesDetailsListAync returns the data for the page with some delay.

Note: Here data is returned with some delay in GetEmployeesDetailsListAync method using Thread.Sleep method.


Note: The above code shows build error in WinRT platform as the Thread.Sleep method is not supported in WinRT. Use Task.Delay to delay the data loading in WinRT as shown in the following code snippet.

WinRT and UWP code

Sample Links:






You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile