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

Grid View ComboBox Column

19 Answers 738 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 27 May 2009, 02:45 PM
Hi,

I have the following:

A Grid View populated by DataSet_A (Columns are Username, Exec_Code, Exec_Name)
Within the Grid View a Combo box column which is populated by DataSet_B (Exec_Code, Exec_Name)  Exec_Code would be a ValueMember and Exec_name would be the DisplayMember

However, the value displayed in the Combo box should be the same value as the Exec_Name from DataSet_A.  When the combo box value is changed the Exec_Code value & Exec_Name value in DataSet_A should be updated.

How can I do this?

Thanks

Barry

19 Answers, 1 is accepted

Sort by
0
Barry
Top achievements
Rank 1
answered on 29 May 2009, 08:22 AM
Hi,

Don't worry I figured this out

Thanks

Barry
0
Nick
Telerik team
answered on 29 May 2009, 08:49 AM
Hello Barry,

Thank you for contacting us. I am glad that you found a solution for your project.

Sincerely yours,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Imran Khan
Top achievements
Rank 1
answered on 07 Sep 2011, 08:42 AM
hi ,
i have the same problem can you plz tell me the solutions
0
Alexander
Telerik team
answered on 08 Sep 2011, 02:39 PM
Hello Imran,

You can set the FieldName property of GridViewComboBoxColumn to the column of RadGridView's DataSource which the GridViewComboBoxColumn refers to. In the Barry's example it is Exec_Code.

The following help article provides additional information regarding the usage of GridViewComboBoxColumn. Please let me know if you have additional questions.

Best regards,
Alexander
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Imran Khan
Top achievements
Rank 1
answered on 08 Sep 2011, 10:23 PM
hi,
thanks for your response.

can you please elaborate the difference b/w of FieldName and ValueMamber property of RadComboBox Column

Thanks.
0
Alexander
Telerik team
answered on 13 Sep 2011, 04:07 PM
Hello Imran,

Thank you for writing back.

ValueMember is the name of the column from the GridViewComboBoxColumn's DataSource which identifies the values in the dropdown of the GridViewComboBoxColumn. For example, if the DataSource of the column is a table 'Car' which contains two columns - 'ID' and 'Brand', you can use 'ID' as ValueMember.

FieldName is the name of the column from the RadGridView DataSource which the GridViewComboBoxColumn is bound to. In the above example, if you bind the RadGridView control to a table 'Driver' which has a FK column 'CarID', you can set 'CarID' as FieldName. When you change the value in the GridViewComboBoxColumn, the DataSource of RadGridView will update with the newly selected car for this driver.

I hope it makes the using of ValueMember and FieldName more understandable.

Best regards,
Alexander
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Don
Top achievements
Rank 1
answered on 06 Oct 2011, 07:29 PM
I have a slightly different scenario. I have a grid with one datasource and a combobox column within that grid that has a different datasource. There is a value in the grid's datasource which corresponds to a value in the grid's datasource. I would like to use that corresponding value to set the value in the combobox's datasource. This will give me the displayvalue in the combobox that I wish the user to see. The idea is to let the user change the displayvalue in the combobox and then persist that change back to the database by saving the corresponding record in the grid's datasource.

I can get the column that is to contain the combobox to show in the grid, but it shows as a textbox. I know I'm missing something and that it is probably a simple something, but I can't figure out just what that something is. Any help would be appreciated!
0
Alexander
Telerik team
answered on 11 Oct 2011, 03:00 PM
Hello Don,

Thank you for your question.

This KB article demonstrates how to create a RadDropDownListEditor with DataSource which depends on the value of another RadGridView cell. Please let me know if it helps you to achieve your requirements.

Best regards,
Alexander
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Don
Top achievements
Rank 1
answered on 24 Oct 2011, 09:53 PM
It kind of helps, but not really. I'm getting the right information to show in my combobox column, but the column is not showing as a combobox. It probably has something to do with setting the active editor, but there isn't a whole lot of documentation on that aimed at someone who has never included a combobox in a grid before using the Telerik controls.
0
Don
Top achievements
Rank 1
answered on 24 Oct 2011, 10:59 PM
What I need to see is a simple set of steps for attaching a RadDropDownListEditor to a GridViewComboBox including all of the events requiring code to initialize things. The sample from your documentation has some of the required events, but not all of them.
0
Alexander
Telerik team
answered on 27 Oct 2011, 08:44 AM
Hello Don,

Thank you for writing back.

The Editors section of the RadGridView documentation includes articles for customizing editors, handling editors’ events, creating custom editors and others. If this documentation is not sufficient for implementing your scenario, please open a new support ticket, attach your project and describe your requirements. It will help us provide you with more specified support.

Best regards,
Alexander
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Laura
Top achievements
Rank 1
answered on 15 Aug 2016, 07:59 PM
The link to this article is not working, please advise, as I would like to do this in my code.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Aug 2016, 05:24 AM
Hello Laura,

Thank you for writing. 

The following KB article demonstrates how you can implement the popular 'cascading combos' scenario where the range of options available in a drop-down list of a combo column depends on the choice made by the end-user in another combo column for the same row:  http://www.telerik.com/support/kb/winforms/gridview/details/cascading-comboboxes-in-radgridview

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Priyanka
Top achievements
Rank 1
answered on 25 Jan 2017, 11:27 AM

Hi,

Actually I want to add 3 items {"Account","Purchase","Dispatch"} in GridViewComboBoxColumn which is in RadGridView. I am not getting a way how to do this. Please help me.

Thanx in advance,

Priyanka

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Jan 2017, 07:42 AM
Hello Priyanka,

Thank you for writing.  

The referred KB article from my previous post demonstrates how to load the available options is a drop down editor considering the selection in another cell on the same row. The GridViewComboBoxColumn. property allows you to specify the collection with the available items. Thus, you can set it to a collection of the mentioned 3 items: "Account", "Purchase", "Dispatch". For the second GridViewComboBoxColumn, the DataSource property must be set to a collection that contains all available options. Then, in the CellEditorInitialized event, you can assign a subset of the whole collection to the editor considering the selection from the other cell. You can have a look at the provided sample project at the bottom of the article. 

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Priyanka
Top achievements
Rank 1
answered on 27 Jan 2017, 05:07 AM

Hello Dess,

Thanks for the reply. It really works. Now I have another problem. Can you tell me how to save radgridview data to the database? I am using RadGridViewElement class and foreach loop for saving all row data in single button click but it shows me error message RadGridView does not use enumeration.

 

Thank You,

Priyanka

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Jan 2017, 10:07 AM
Hello Priyanka, 

Thank you for writing back. 

Please refer to the following help article which demonstrates how to save the data to your database: http://docs.telerik.com/devtools/winforms/gridview/populating-with-data/updating-the-database-with-ado.net

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Bao
Top achievements
Rank 1
answered on 13 Sep 2017, 04:14 AM

Hi Dess, 

I have a gridview with columns (Name, Vendor, Quantity). So how can i bind datasource for Vendor column with code:

  RadDropDownListEditor ddl = e.ActiveEditor as RadDropDownListEditor;
            if (ddl != null)
            {
                RadDropDownListEditorElement vendor = ddl.EditorElement as RadDropDownListEditorElement;
                vendor.DataSource = vendorBindingSource;
                vendor.DisplayMember = "VendorName";
                vendor.ValueMember = "VendorId";
            }

and it does not keep displaymember when i leave out the field : https://www.screencast.com/t/YTm4Q5LsbR

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Sep 2017, 11:13 AM
Hello Bao, 

Thank you for writing back. 

In order to keep the cell's value when leaving the editor for a GridViewComboBoxColumn, it is necessary the selected value to be valid considering the DataSource collection applied to the column. The following help article is quite useful how to setup the GridViewComboBoxColumn: http://docs.telerik.com/devtools/winforms/gridview/columns/column-types/gridviewcomboboxcolumn

The RadDropDownListEditorElement.DataSource must be a subset of the DataSource for the column. Otherwise, the cell's value will be lost.

I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Barry
Top achievements
Rank 1
Answers by
Barry
Top achievements
Rank 1
Nick
Telerik team
Imran Khan
Top achievements
Rank 1
Alexander
Telerik team
Don
Top achievements
Rank 1
Laura
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Priyanka
Top achievements
Rank 1
Bao
Top achievements
Rank 1
Share this question
or