This is a migrated thread and some comments may be shown as answers.

RadGridView ComboBox

1 Answer 1476 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 30 Nov 2019, 08:10 PM

C#, Winforms

I have an XML data source (Main) that I am binding to my gridview. I want one column to be a combobox. I'm using a separate XML file (Options) for the combobox options. 

Questions:

1) When I set the data source for the combobox to the Options dataset, the column is blank. I want it to be the value listed in the Main dataset. The result I seek is that when the grid loads, the values from the Main dataset are loaded. The user can then edit the combobox column by selecting from the drop down that is populated from the Options dataset. How can I achieve this?

2) Obviously, I want to save these back edits back to the main dataset. How can I rebind the column to the Main dataset?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Dec 2019, 01:33 PM
Hello, Chris,

After the grid is populated with data (after setting RadGridView.DataSource) and its columns are automatically generated, you can remove a certain column and add a new one, e.g. GridViewComboBoxColumn. You need to apply another collection for DataSource of the column together with column's DisplayMember and ValueMember properties. Note that the ValueMember needs to correspond to the values that you have in the cell, e.g. if you have ID and Name column and you have stored the IDs in the grid cells, in order to display the correct value when loading the grid, make sure that you specify the column's FieldName to the respective field in the applied RadGridView.DataSource collection. Thus, the cells' values will be populated with the respective values in the grid. Then, if you edit a cell, the value will be updated to the underlying DataBoundItem respectively. 

Additional information how to setup the GridViewComboBoxColumn is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/columns/column-types/gridviewcomboboxcolumn 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or