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

Display Value instead of Code in Column

2 Answers 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Guy
Top achievements
Rank 1
Guy asked on 18 May 2011, 10:15 AM
This question must be one of the top FAQ.  But I cannot find a concise, clear answer.  Let me try for a concise, clear question.

Given a "Lookup" table:

Code  Direction
1        South
2        East
3        North
4        West

And a "Main" table:

Name Vehicle Code
Bert    Truck1  1
Mac    Truck2  4

How do I make the RadGrid display as follows?  My RadGrid is readonly so no pulldowns are necessary on the third column.

Bert Truck1 South
Mac Truck2 West

I'm using OpenAccess ORM so my tables are in POCOs Lookup and Main.

Does the third column have to be a ComboBox column?  Or do I use CellFormatting event?  If I use a combobox column how do I set the three parameters (Main.Code, Lookup.Code and Lookup.Direction)?

Regards,
Guy


2 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 18 May 2011, 12:54 PM
Hello Guy,

Just register to the DataBindingComplete, get the ComboBoxColumn and set the display member to the combo box column's value member and you will see the required value there.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
Ivan Petrov
Telerik team
answered on 20 May 2011, 05:06 PM
Hi Guy,

Thank you for writing.

The solution that Emanuel suggested is correct and will do the job. You should use a combo box column and set its ValueMember, FieldName and DisplayMemeber properties and you will get the desired effect. You can find more info in the following help article regarding GridViewComboBoxColumn.

I hope this helps. If you have further questions, I will be glad to help.

Regards,
Ivan Petrov
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
Guy
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Ivan Petrov
Telerik team
Share this question
or