How to bind an enum property to a GridDropDownColumn

4 posts, 0 answers
  1. JFr
    JFr avatar
    4 posts
    Member since:
    Apr 2009

    Posted 30 May 2009 Link to this post

    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
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 02 Jun 2009 Link to this post

    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.
  3. JFr
    JFr avatar
    4 posts
    Member since:
    Apr 2009

    Posted 02 Jun 2009 Link to this post

    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
  4. Prem
    Prem avatar
    2 posts
    Member since:
    May 2017

    Posted 10 Oct 2017 Link to this post

    How can i bind Grid dropdown list from enum?
Back to Top