Flexgrid binding issue

Posted by: ray on 7 October 2022, 12:27 am EST

    • Post Options:
    • Link

    Posted 7 October 2022, 12:27 am EST - Updated 7 October 2022, 12:35 am EST

    I have a WPF form with two grids on it as shown in the image. The top grid is a (SF) SyncFusion DataGrid and the bottom grid is a (C1) C1:Flexgrid.

    In the XAML, both grids are bound to the same source Data Table in the same way

    <c1:FlexGrid ItemsSource="{Binding DtBookings}"... 
    <DataGrid ItemsSource="{Binding DtBookings}"...

    When I click on the grid I want the entire Booking object available to me so I fill the datatable like this and bind the grid to it:

    The DataType of dtBookings is a “Booking” object:

    dt.DataType = typeof(Booking);

    The “Booking” object is a complex class containing other complex classes, namely the “Person” object, So we can have for example: (Customer is a Person object).


    Finally the Booking.ToString() is overridden so that when it is bound to a control instead of seeing “Bookings.Models.Booking” written into the celltext we can see something useful like customer’s name “John Doe”.

            public override string ToString()
                return base.Customer.DisplayName;

    When I run the code above the SF grid is populated and the C1 is not.

    If I change the dtBookings.DataType from Booking to Person:

    dt.DataType = typeof(**Person**);

    and then populate the datatable with the Bookings.Customer then the C1 grid will work and display the contents too.

    So effectively C1 will see Booking.Person.ToString(); But it won’t see Booking.ToString();

    But of course I only have the Person object now and not the entire Booking.

    Even if I change the ToString() to a local variable like return Bookings.HelloWorld it won’t work.

    Why is the C1 Flexgrid not displaying the Booking Object, but it will display the Person object?!

  • Posted 9 October 2022, 9:09 pm EST

    Hi Raymond,

    From the code snippet and the information provided by you,

    dt.DataType = typeof(Booking);

    we assume ‘dt’ to be a DataTable type object. But unfortunately, we could not find any direct property named ‘DataType’ in DataTable class. Please tell us how you have implemented it so that we can assist you accordingly.

    We would appreciate it if you could provide a sample application replicating the mentioned behavior.



  • Posted 9 October 2022, 10:05 pm EST

    Hello Aastha.

    The application is quite complex so it will be hard to provide a demo. If you want to, we could arrange a screen share over Teams at some time. I think this could be an important issue for you?

    The Column has the DataType property you are seeking.

    This is the code that’s called to setup the DataTable in memory. This is the DataTable that we bind to. The first row is of typeof(Person), the rest of the rows are of type Booking.

        public void SetupDataTable()
            //this is the System.Data.Datatable that the Instructors grid is bound to.
            ///Here is the first column for the Pilots
            if (DtBookings == null)
                DtBookings = new();
            int i = 0;
            //This adds just the first column header text
            DataColumn header = new("Instructors");
            header.DataType = typeof(Person);
            //add the columns for each time slot across the top
            foreach (var t in slotTimes)
                if (i >= slotTimes.Count -1)
                DataColumn dc = new DataColumn(slotTimes[i] + " - " + slotTimes[++i], typeof(Booking));
                //dc.DataType = typeof(Booking);   //cells in main grid area are type Booking
            ///Add the rows for each pilot
            DataRow dr;
            i = 0;
            foreach (var p in Pilots)
                dr = DtBookings.NewRow();
                p.GridRow = i++;
                dr[0] = p;

    This is the code that populates the DataTable with the bookings.

    If I change the column type above to typeof(Person) and this to Booking.Customer then the C1 grid will work. It will display the Person object but not the Booking object.

        void DisplayBookings()
            bookingsByDate = new ObservableCollection<BookingModel>(BookingsData.GetBookingsByDate(bookingDate));
            foreach (Booking booking in bookingsByDate)
                LoadUpBookingSubClasses(booking); //This gets booking.customer etc.
             //This adds the booking to the DataTable.
                DtBookings.Rows[GetPilotGridRowLocation(booking)][booking.SlotTimeId] = booking;
  • Posted 10 October 2022, 1:59 am EST

    Also to add, the first Column.DataType is set to Person object. The rest are set to Booking object.

  • Posted 10 October 2022, 11:08 pm EST

    Hi Raymond,

    We have created a sample application with the information provided by you, but could not replicate the issue on our end. We have also tested the scenario with the .NET5 build but did not find any issues.

    We request you go through the attached sample application for full implementation. (See BookingBindingIssue.zip)

    Best Regards,


  • Posted 11 October 2022, 12:22 am EST

    Hello Aastha.

    I have spent the last hour working on it.

    My BookingModel is “internal”. I changed it to “public” and now it is working.

    My BookingViewModel is “internal”.

    Why does this affect C1 and not SF?

  • Posted 12 October 2022, 4:51 pm EST

    Hi Raymond,

    Our Flexgrid control uses Reflection API to fetch the Type information for binding purposes. This, by default, gathers information about publically accessible attributes. Hence, changing the accessibility of the ‘BookingModel’ class to public resolved your issue when you used ComponentOne Flexgrid control.

    Since we are unsure about the implementation of SF Datagrid, we cannot help you with the information regarding its behavior.

    Best Regards,


  • Posted 12 October 2022, 8:28 pm EST

    Thank you. We can close this thread now. :slight_smile:

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels