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

How to bind an enum property to a GridDropDownColumn

3 Answers 301 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JFr
Top achievements
Rank 1
JFr asked on 30 May 2009, 09:57 PM
Good evening everyone,

I'm working with data source that returns a business object containing several properties of type enum.  Is there a recommended way of binding such properties to GridDropDownColumn for displaying and editing?  So far, adding values to the control programmatically via ItemDataBound seems to be very tedious and inefficient.  Pointers or some guidelines on how to work with enums and the RadGrid would be excellent.

Thanks

        \Steve

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 02 Jun 2009, 04:06 PM
Hi Steve,

The GridDropDownColumn is designed to be bindable to various data source controls that provide reference to the items in the dropdown list. While various data sources are supported, there is no automatic way to bind a data-bound control to an enum data type. Therefore, the enumerated values need to be traversed and their text values added as items for the GridDropDownColumn when the grid row is going in edit mode.

Best wishes,
Veli
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
JFr
Top achievements
Rank 1
answered on 02 Jun 2009, 06:36 PM
Hi Veli,

Giving it some thought I came up with a similar solution.  I created a generalized business object that translates the numeric values into strings, thus allowing for easy binding to the GridDropDownColumn.  One minor drawback is that I needed to declare two bound columns for displaying and editing a single value: one GridBoundColumn given the numeric values from the business object's enums and another GridDropDownColumn (that is associated an ObjectDataSource, the generalized business object) with its ListValueField and TextValueField specified accordingly.  That way no programming in the presentation layer is involved whatsoever.  Everything is handled in the business logic.

Thanks for your answer anyway.  Just wanted to make sure that there is no recommended approach to that sort of problem.

        \Steve
0
Prem
Top achievements
Rank 1
answered on 10 Oct 2017, 10:40 AM
How can i bind Grid dropdown list from enum?
Tags
Grid
Asked by
JFr
Top achievements
Rank 1
Answers by
Veli
Telerik team
JFr
Top achievements
Rank 1
Prem
Top achievements
Rank 1
Share this question
or