GridViewComboBoxColumn Displays Empty Cell For Newly Added Values

5 posts, 1 answers
  1. Joel
    Joel avatar
    2 posts
    Member since:
    Apr 2013

    Posted 04 Jun 2013 Link to this post

    I'm a bit new to the RadControls, and C# in general, so bear with me if the trouble I am facing is due to some terribad implementation. Anyway, here is the problem.

    I have a single, form that has a number of radGridViews on it. Most of the grids are very simple lists with a schema that consists of not much more than an 'ID'{int} and a 'Name'{string}. I also have one master grid with a number of GridViewComboBoxColums that reference the aforementioned lists. I'm using entity framework models for the datasources, which I assign using the below

    VendorManagerEntities context = new VendorManagerEntities();
    protected override void OnLoad(EventArgs e)
        contactBindingSource.DataSource = context.Contacts;
        statusBindingSource.DataSource = context.Status;
        priorityBindingSource.DataSource = context.Priorities;
        categoryBindingSource.DataSource = context.Categories;
    Note: The RadGridViews and GridViewComboBoxColums are sharing the same DataSources, a.k.a. I have a grid for status's and a combo box on another grid that both use the statusBindingSource.

    When I start the application it populates the grids, columns, and combo boxes from the database; no problem is had. If I then add a row, new value, to one of the Grids that value will show up in the corresponding combobox, but if I select the new value, which apears correctly in the drop down list, the cell will be blank. The correct value is selected, and it submits correctly to the database/model, but it does not display. I suspect that is has something to do with the DisplayMember, but I'm not sure. If I restart the program, and the form is recreated, the new values that were gotten from the database display correctly. What I would like is for the new values to display in their cells, without having to close and restart the form application.

    I warn that most of the grid creation was done with the designer, so I am hesitant to post too much of that generated code, but I'll try and get the important bits in here

    private void InitializeComponent()
    this.radGrid_Contacts = new Telerik.WinControls.UI.RadGridView();  // Contacts is "supergrid" that has a ton of combo boxes
    this.contactBindingSource = new System.Windows.Forms.BindingSource(this.components);
    this.radGrid_Statuses = new Telerik.WinControls.UI.RadGridView(); // Status is a simple list, every status wants to some day be part of a combobox
    this.statusBindingSource = new System.Windows.Forms.BindingSource(this.components);
    // ...
    // Contact Rad Grid
    this.radGrid_Contacts.MasterTemplate.AutoGenerateColumns = false;
    this.radGrid_Contacts.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
    gridViewDecimalColumn1.DataType = typeof(int);
    gridViewDecimalColumn1.EnableExpressionEditor = false;
    gridViewDecimalColumn1.FieldName = "ID";
    gridViewDecimalColumn1.HeaderText = "ID";
    gridViewDecimalColumn1.IsAutoGenerated = true;
    gridViewDecimalColumn1.Name = "ID";
    gridViewDecimalColumn1.ReadOnly = true;
    gridViewComboBoxColumn4.DataSource = this.statusBindingSource;
    gridViewComboBoxColumn4.DataType = typeof(int);
    gridViewComboBoxColumn4.DisplayMember = "Name";
    gridViewComboBoxColumn4.EnableExpressionEditor = false;
    gridViewComboBoxColumn4.FieldName = "Status_ID";
    gridViewComboBoxColumn4.HeaderText = "Status";
    gridViewComboBoxColumn4.Name = "Status_ID";
    gridViewComboBoxColumn4.ValueMember = "ID";
    gridViewComboBoxColumn4.Width = 129;
    this.radGrid_Contacts.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {
    this.radGrid_Contacts.MasterTemplate.DataSource = this.contactBindingSource;
    this.radGrid_Contacts.MasterTemplate.DataSource = this.contactBindingSource;
    this.contactBindingSource.DataSource = typeof(VendorManager.Contact);
    // radGrid_Statuses
    gridViewDecimalColumn6.DataType = typeof(int);
    gridViewDecimalColumn6.EnableExpressionEditor = false;
    gridViewDecimalColumn6.FieldName = "ID";
    gridViewDecimalColumn6.HeaderText = "ID";
    gridViewDecimalColumn6.IsAutoGenerated = true;
    gridViewDecimalColumn6.IsVisible = false;
    gridViewDecimalColumn6.Name = "ID";
    gridViewDecimalColumn6.Width = 301;
    gridViewTextBoxColumn23.EnableExpressionEditor = false;
    gridViewTextBoxColumn23.FieldName = "Name";
    gridViewTextBoxColumn23.HeaderText = "Status Name";
    gridViewTextBoxColumn23.IsAutoGenerated = true;
    gridViewTextBoxColumn23.Name = "Name";
    gridViewTextBoxColumn23.Width = 909;
    gridViewTextBoxColumn24.DataType = typeof(VendorManager.TrackableCollection<VendorManager.Contact>);
    gridViewTextBoxColumn24.EnableExpressionEditor = false;
    gridViewTextBoxColumn24.FieldName = "Contacts";
    gridViewTextBoxColumn24.HeaderText = "Contacts";
    gridViewTextBoxColumn24.IsAutoGenerated = true;
    gridViewTextBoxColumn24.IsVisible = false;
    gridViewTextBoxColumn24.Name = "Contacts";
    gridViewTextBoxColumn24.Width = 151;
    this.radGrid_Statuses.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {
    this.radGrid_Statuses.MasterTemplate.DataSource = this.statusBindingSource;
    this.radGrid_Statuses.Name = "radGrid_Statuses";

    I hope I explained my problem thorougly, if not please tell me so that I can elaborate on anything important that I missed. Thank you in advance for the help.


    EDIT: Quite interstingly, if I right click and clear the value on the cell it displays correctly.
  2. Joel
    Joel avatar
    2 posts
    Member since:
    Apr 2013

    Posted 05 Jun 2013 Link to this post

    I see that I might have neglected to include the version information for the products and software I am using.

    • Windows 7
    • Telerik UI Controls, Windows Forms, Ver. 2013.1.321.40
    • .Net 4.0
    • Visual Studio 2010

    Thanks again.

    EDIT: So, I noticed that I only see this behavior if I save the data to the database with the context.SaveChanges() method. If I do not call that method, then I do not have a problem. However, I need to be able to save my changes.
  3. DevCraft R3 2016 release webinar banner
  4. Answer
    Ivan Petrov
    Ivan Petrov avatar
    701 posts

    Posted 06 Jun 2013 Link to this post

    Hi Joel,

    Thank you for writing.

    When you add a new value to one of the grids it adds it to its underlying data source. At that point entity framework knows it has to add a new record in a table in the database. At the same time this record does not have a valid id (which usually is auto-incremented and is assigned by the SQL server). When you call the SaveChanges method of your context the record is pushed to the database and its Id is retrieved and store in it. This where the issue comes from, the combo box column of RadGridView stores its values in an internal keyed collection where the items values are used for keys. When the new id value is retrieved from the database the combobox internal collection has an invalid item because its value changed. I have logged this issue in our Public Issue Tracking System - PITS. You can track the progress of this issue, subscribe for status changes and add your vote comment on the following link - PITS Issue. To workaround the issue you can reset the combo box column data source after you call the SaveChanges method. To reset it set it to null and then to the data source.

    I have also updated your Telerik Points for bringing this issue to our attention.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Ivan Petrov
    RadChart for WinForms is obsolete. Now what?
  5. Filippo
    Filippo avatar
    4 posts
    Member since:
    Feb 2012

    Posted 06 Jul 2015 in reply to Ivan Petrov Link to this post


      I have the same problem. How can I track this link: ?

      Thank you for your help,


  6. Stefan
    Stefan avatar
    2891 posts

    Posted 07 Jul 2015 Link to this post

    Hello Filippo,

    Our PITS system was migrated to a Feedback Portal. The issue page is here:

    As you can see, it was resolved back in Q2 2013.

    Should you continue experiencing issues, feel free to open a new case and we will investigate it.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft R3 2016 release webinar banner