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

Databound GridViewComboBoxColumn Problem

1 Answer 76 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris Kirkman
Top achievements
Rank 1
Chris Kirkman asked on 19 Apr 2011, 03:57 PM

I have a column defined in my gridview.  It's name is "Energy".

I use the following code to bind my object to it.  The object is a generic List<> of other objects.

 

 

((

 

GridViewComboBoxColumn)m_grd.Columns["Energy"]).DataSource = m_snc.Configuration.CurrentRadiationDevice.Energies;

 

 

 

 


The binding seems to work fine as far as display is concerned.  Each "Energy" object has a ToString() override which allows me to see what I want in cases where I bind it to drop down's (like in this case).  The combo box is filled with the appropriate display values; however when I select an item from the combo box and check to see the value's type, it is always a System.String instead of the object type of the item that is selected.  In this case the expected behavior of the following method would be my custom object's type instead of System.String.

 

 

row.Cells["Energy"].Value.GetType()

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 22 Apr 2011, 10:37 AM
Hello Chris,

Thank you for your question.

The type of a GridViewComboBoxColumn cell value is the type of the column's ValueMember. You can discover the type of the displayed in the column object using column's DataSource.

I hope it helps.

Best regards,
Alexander
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Chris Kirkman
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or