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

Gridview Combobox Column Valuemember being the object itself

3 Answers 324 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Myth
Top achievements
Rank 1
Myth asked on 28 Jan 2010, 12:38 PM
I'm having some trouble figuring out how to use the combobox column. In my gridview i'm trying to display a List(Of OrderLine).

the list is filled with "OrderLine" Objects, with the following property's:
unitcount as Integer,
unitPrice as Double,
product as Product - The product object has an id and name field, being respectively an integer and String.

The product column is the combobox column, and is filled by setting the datasource als a List(Of Product)

When viewing the list, I cant seem to get the product column to show the product name. Furthermore when i try to add a new line, I can't get the value to be the product object either. Is there a way i can set the valuemember as the column object itself, instead of one of its properties?

3 Answers, 1 is accepted

Sort by
0
Myth
Top achievements
Rank 1
answered on 28 Jan 2010, 12:48 PM
bypassed the problem by setting only keeping the id in the column instead of the entire object. This does mean I will need to do a lookup when saving though.
0
Nikolay
Telerik team
answered on 02 Feb 2010, 05:21 PM
Hello Myth,

Indeed, in your scenario you need to set the ValueMember to the id of the object instead of the object itself. If you save an object in a cell, you will need to determine which object is which when you try to save the selections, since it is out of RadGridView scope to contain references or other object mappings in it.

Best wishes,
Nikolay
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Erwin
Top achievements
Rank 1
answered on 05 Oct 2010, 10:35 PM
You could solve this problem by simply adding a "Self" property to the object, that returns it!

In VB:
Public ReadOnly Property Self() As YourObjectType
  Get
    Return Me
  End Get
End Property

Then you would use "Self" as the ValueMember.
Tags
GridView
Asked by
Myth
Top achievements
Rank 1
Answers by
Myth
Top achievements
Rank 1
Nikolay
Telerik team
Erwin
Top achievements
Rank 1
Share this question
or