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

Add Empty Column when SfDataGrid is bound to DataTable


This is a graphical issue.

I don't know how to add an empty column to SfDataGrid when ItemSource is bound to a DataTable, because i dont know how many columns will be loaded.

This is the result i would like to achieve using ColumnSizer="AutoWithLastColumnFill".

 In this case i set the columns in XAML.

But when i bound ItemSource to a DataTable, columns are auto-generated because i dont know at design time the table resulting from a user generated query.

The default behaviour of SfDatagrid is this one


How can i add an empty column when SfDataGrid is bound to DataTable


1 Reply

SJ Sathiyathanam Jeyakumar Syncfusion Team January 19, 2023 05:20 PM UTC

Hi Michele,

Your requirement can be achieved by adding the dummy columns in a loaded event of datagrid. Refer to the below code snippets.

Here's an example of how you can achieve this:


this.DataGrid2.Loaded += DataGrid2_Loaded;


private void DataGrid2_Loaded(object sender, RoutedEventArgs e)


    this.DataGrid2.Columns.Add(new GridTextColumn()


        MappingName = "Dummy" ,

        HeaderText = "",

        AllowFiltering = false,

        AllowGrouping = false,

        AllowSorting = false,

        AllowEditing = false,





Attachment: DataTableDemo_611504ba.zip

Live Chat Icon For mobile
Up arrow icon