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

Binding Using DataTable

Hi I would to ask help regarding binding data to the data grid. On the program we are creating, we have this dynamic grid columns which requires manually setting the columns.

Just to give you an info, the data to bind does not have any "Class" to be used as an ObservableCollection, instead, we are manually creating the DataTable that contains the generated data.

The columns for this is also dynamic which comes from a source information from the server. So basically, the data grid will contain different view of columns depending on the data populated.

How can you help me to make this thing works. We are using SfDataGrid as this is the only component which we can really use on our project.

A simple example below which I hope can give you idea how can you possibly help me.

private void BuildGrid()
lock (_lock)

                foreach (GridColumnDefinition colDef in App.CurrentApp.DynamicGridColumns)
                    GridTextColumn textColumn = new GridTextColumn();
                    textColumn.HeaderText = colDef.HeaderText;
                    textColumn.MappingName = colDef.Name;
                    textColumn.LineBreakMode = LineBreakMode.WordWrap;
                    textColumn.TextAlignment = TextAlignment.Center;


var bindTask = GenerateDataTable(dynamicSRC); *
GridData = await bindTask; **

* dynamicSRC - is the dynamic source contains
** GridData - is the DataTable


<syncfusion:SfDataGrid x:Name="dataGrid" ItemsSource="{Binding GridData}" SelectionMode="Single" ColumnSizer="Star" AutoGenerateColumns="False" RowHeight="55" HeaderRowHeight="50" ScrollingMode="PixelLine"
                                   Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" VerticalOptions="FillAndExpand">

After we have successfully populated the DataTable, it seems that there is nothing happen to the datagrid. No Columns, No Rows, nothing at all. We will be glad at most if you can help us regarding this problem. We just really can't figure out how to successfully work this.

Thank you.

1 Reply

DS Divakar Subramaniam Syncfusion Team August 4, 2016 01:17 PM UTC

Hi Joseph, 
Thanks for contacting Syncfusion Support. 
We have analyzed your query. If your requirement is to bind a DataTable collection to SfDataGrid, then it is not possible as Xamarin.Forms does not have support to System.Data in PCL. Thus it is not possible to bind a DataTable collection in SfDataGrid for Xamarin.Forms. 
In case if you are trying to bind dynamic objects in a table format for which you had meant as DataTable, we regret to inform you that Xamarin.Forms does not support “Dynamic Binding. It is a limitation in Xamarin.Forms without a JIT. Please refer the below Bugzilla link for more details.  
However, we have support for Dynamic Binding in our Xamarin.Android control and we would suggest you to try it if your requirement is for Android alone. 

Live Chat Icon For mobile
Up arrow icon