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

how to use datatable with SfDataPager


I need to use Datatable with sfdatagrid but with using SfDataPager.

I saw that I can't but I need any method to use or convert the Datatable to be appropriate with sfdatagrid.


1 Reply

DM Dhanasekar Mohanraj Syncfusion Team December 8, 2022 02:07 PM UTC

Hi Mohamad,

By default, SfDataPager doesn’t accept DataTable as a Source. We have already documented this as a limitation as shown below,

However, you can achieve your requirement to use the DataTable by using ExpandoObject shown below,


private DataTable dataTableCollection;

private ObservableCollection<dynamic> dynamicCollection;

public Form1()



    this.WindowState = FormWindowState.Maximized;

    //Gets the data for DataTable object.

    dataTableCollection = GetGridData();


    //Convert DataTable collection as Dyanamic collection.

    dynamicCollection = new ObservableCollection<dynamic>();

    foreach (System.Data.DataRow row in dataTableCollection.Rows)


        dynamic dyn = new ExpandoObject();


        foreach (DataColumn column in dataTableCollection.Columns)


            var dic = (IDictionary<stringobject>)dyn;

            dic[column.ColumnName] = row[column];




    DynamicOrders = dynamicCollection;

    sfDataGrid1.AutoGenerateColumns = true;

    sfDataGrid1.DataSource = DynamicOrders;




private ObservableCollection<dynamic> _dynamicOrders;


/// <summary>

/// Gets or sets the dynamic orders.

/// </summary>

/// <value>The dynamic orders.</value>

public ObservableCollection<dynamic> DynamicOrders




        return _dynamicOrders;




        _dynamicOrders = value;




public DataTable DataTableCollection


    get { return dataTableCollection; }

    set { dataTableCollection = value; }


Here we have prepared the sample based on your scenario. Please have a look at this.

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


Dhanasekar M.

Attachment: SfDatagridDemo__906b287f.zip

Live Chat Icon For mobile
Up arrow icon