How to Bind DataTable to DataGrid in Xamarin | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (179).NET Core  (28).NET MAUI  (214)Angular  (110)ASP.NET  (51)ASP.NET Core  (83)ASP.NET MVC  (90)Azure  (41)Black Friday Deal  (1)Blazor  (226)BoldSign  (15)DocIO  (24)Essential JS 2  (109)Essential Studio  (200)File Formats  (69)Flutter  (133)JavaScript  (226)Microsoft  (120)PDF  (81)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (942)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (45)Webinar  (52)Windows Forms  (61)WinUI  (71)WPF  (163)Xamarin  (160)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (9)Business intelligence  (55)Button  (4)C#  (158)Chart  (140)Chart of the week  (54)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (70)Development  (658)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (14)Excel  (43)Extensions  (22)File Manager  (7)Gantt  (19)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (512)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (4)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (14)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (393)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (614)What's new  (333)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
DataTable Binding Support in Xamarin DataGrid

How to Bind DataTable to DataGrid in Xamarin

As many of you know, .NET Standard 2.0 introduced support for DataSet and DataTable. With that, we got overwhelming demand for support to bind DataTable to the Xamarin.Forms DataGrid. We are happy to announce that this feature is available with our 2019 Volume 3 – Beta release.

In this blog, I am going to walk you through how to bind the DataTable class to the Xamarin.Forms DataGrid control.

Data binding

Let’s create a simple data table with Order details data. You won’t need any additional stuff for binding, just create the data table and assign it directly to DataGrid’s ItemsSource property. You can also bind the data table from the data set.

ViewModel creation

Create a view model class in the Xamarin project similar to the one in the following code example

public class ViewModel
    public ViewModel()
        DataTableCollection = GetDataTable();
    public DataTable DataTableCollection { get; set; }

    private DataTable GetDataTable()
        DataTable dataTable = new DataTable();
        dataTable.Columns.Add("Order ID", typeof(double));
        dataTable.Columns.Add("Customer Name", typeof(string));
        dataTable.Columns.Add("Customer ID", typeof(string));
        dataTable.Columns.Add("Country", typeof(string));
        dataTable.Rows.Add(1001, "Maria Anders", "ALFKI", "Germany");
        dataTable.Rows.Add(1002, "Ana Trujilo", "ANATR", "Mexico");
        dataTable.Rows.Add(1003, "Antonio Moreno","ENDGY", "Mexico");
        dataTable.Rows.Add(1004, "Thomas Hardy", "ANTON", "UK");
        dataTable.Rows.Add(1005, "Christina Berglund", "BERGS", "Sweden");
        dataTable.Rows.Add(1006, "Hanna Moos", "BLAUS", "Germany");
        dataTable.Rows.Add(1007, "Frederique Citeaux", "BLONP", "France");
        dataTable.Rows.Add(1008, "Martin Sommer", "BOLID", "Spain");
        dataTable.Rows.Add(1009, "Laurence Lebihan", "BONAP", "France");
        dataTable.Rows.Add(1010, "Kathryn", "BOTTM", "Canada");
        dataTable.Rows.Add(1011, "Tamer", "XDKLF", "UK");
        dataTable.Rows.Add(1012, "Martin", "QEUDJ", "US");
        dataTable.Rows.Add(1013, "Nancy", "ALOPS", "France");
        dataTable.Rows.Add(1014, "Janet", "KSDIO", "Canada");
        dataTable.Rows.Add(1015, "Dodsworth", "AWSDE", "Canada");
        dataTable.Rows.Add(1016, "Buchanan", "CDFKL", "Germany");
        dataTable.Rows.Add(1017, "Therasa", "WSCJD", "Canada");
        dataTable.Rows.Add(1018, "Margaret", "PLSKD", "UK");
        dataTable.Rows.Add(1019, "Anto", "CCDSE", "Sweden");
        dataTable.Rows.Add(1020, "Edward", "EWUJG", "Germany");
        dataTable.Rows.Add(1021, "Anne", "AWSDK", "US");
        dataTable.Rows.Add(1022, "Callahan", "ODKLF", "UK");
        dataTable.Rows.Add(1023, "Vinet", "OEDKL", "France"); 
        return dataTable;

Binding ItemsSource in XAML

In the main page, add the necessary XML namespace to use SfDataGrid control, set the BindingContext of the page to the ViewModel class, and bind the ItemSource of SfDataGrid with the DataTableCollection.

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="" 
        <local:ViewModel x:Name="ViewModel"/>

    <syncfusion:SfDataGrid x:Name="dataGrid"
                           ItemsSource="{Binding DataTableCollection}">

DataTable binding in Xamrin Data Grid

DataTable binding in Xamarin Data Grid

CRUD operations

DataGrid automatically refreshes the UI whenever we add, delete or modify the rows of the underlying DataTable collection.

Data operations

DataGrid supports various data operations to represent the data in it. The following are supported by default:

  • Sorting (including multicolumn sorting)
  • Grouping (including multicolumn grouping)
  • Filtering
  • Summaries


You can sort columns with the various built-in options such as multicolumn sorting and tri-state sorting. But custom sorting is not supported.

In the following screenshot, the data grid is sorted in ascending order with respect to the Customer Name column.Data grid is sorted in ascending order with respect to the Customer Name

Data Grid sorted ascending with respect to the Customer Name


The data can be organized in a hierarchical structure based on matching field values. Multigrouping and custom grouping are also supported.Data grouped with respect to Country in Data Grid

Data grouped with respect to Country in Data Grid


DataGrid’s built-in View.Filtering is not supported for the DataTable class. But, you can filter the records using DataTable’s DataView.RowFilter property.

In the following example, the DataView.RowFilter property is set as “[Country] = ‘Canada’”.Row filter applied to the Data Grid

Row filter applied to the Data Grid


All summary types supported by DataGrid are supported for DataTable, i.e. group summary, caption summary, and table summary.Summaries displayed in the Data Grid

Summaries displayed in the Data Grid

Other features

The support for all other features, such as stacked headers, row drag and drop, unbound column, and unbound row, of DataGrid are available. You can refer to the user guide to learn more about the DataGrid’s feature sets.


I hope you enjoyed this quick walk-through of DataTable binding support in DataGrid. This support is available with our 2019 Volume 3 beta release, which you can download from here.

If you have any questions or require clarification about this feature, please let us know in the comments below. You can also contact us through our support forumDirect-Trac, or our feedback portal. We are happy to assist you!


Share this post:

Comments (7)

[…] How to Bind DataTable to DataGrid in Xamarin (Neelakandan Kannan) […]

binding DataTable, but SwitchColumn binding not work how to binding ?

1. ‘True’ DataTable column string type not working

2. ‘true’ DataTable column bool type not working

,,, Class Binding is working

Hi 인식 남,

The switch column support to bind the `true` or `false` values of bool type properties. Binding is not supported for string type of properties. The reported issue with the “Switch column binding is not working when binding bool type of properties” has been fixed and the fix will be included in our upcoming 2019 Volume 3 Service Pack release.

A good tool to show data effeciently. I want to ask if this datagrid supports features like editing data, deleting, inserting and updating just like one in DevExpress DataGrid tool ?

Hi Farooq,
Thanks for your valuable feedback.
Our DataGrid supports all CRUD operations and all other essential features like sorting, grouping, summary rows and filtering. You can also check out our user guide and feature sets in the below link,
User Guide:
Feature tour:

hi,am having issue in the updating ui when i add delete insert or remove some row the ui is not updating

Hi Asfund,

Thanks for trying out Syncfusion’s datagrid and reaching out to us. I have checked the datagrid with a data table bound to it as the items source and tried all CRUD operations on it via button click and it is working fine. You can find the tested sample from this link

Do check out the sample and let me know if my replication is any different from yours. Also I would like to know more details regarding your use scenario so that we could check and assist you better. Is grouping enabled in your grid?, does the issue have a specific replication procedure ?, which rows are not updating ( normal data row or summary rows) ?, how do you perform the crud operations ?, is the issue specific to any single platform ? etc. Awaiting to hear from you and resolve this for you.

Comments are closed.

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed