RadColorPicker in grid cell template

4 posts, 0 answers
  1. John
    John avatar
    25 posts
    Member since:
    Feb 2008

    Posted 10 Sep 2008 Link to this post


     I want to display a RadColorPicker in a grid cell (either in a radGrid or an Infragistics UltraWebGrid, I'm not fussy). I can't figure out how to successfully do this in an UltraWebGrid cell template, haven't tried the radGrid. Is there any sample code or advice you can send my way to achieve this?

    Many Thanks,

  2. Svetlina Anati
    Svetlina Anati avatar
    2795 posts

    Posted 12 Sep 2008 Link to this post

    Hello John,

    You can display a RadColorPicker in a grid cell by putting it into the grid column's Item Template. For RadGrid this should be done in the following manner:

       <telerik:GridTemplateColumn HeaderText="TextColor" UniqueName="TextColor">  
                                    <telerik:RadColorPicker ID="defaultRadColorPicker1" runat="server" Preset="Standard">  

    In case your question is about binding a color, please note that you cannot provide the color through declarative binding because only primitive type properties such as string, int, bool are bindable declaratively. Therefore .

    What I can suggest is to use the RadGrid's Item_DataBound server event handler and set the selected color  using the code behind where you can do the needed casts as shown below:

     picker.SelectedColor = ColorTranslator.FromHtml((DataBinder.Eval(e.Item.DataItem, "Color").ToString()));  

    For your convenience I attached a sample demo project which demonstrates the above mentioned approach.

    All the best,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Dédé
    Dédé avatar
    60 posts
    Member since:
    May 2009

    Posted 19 May 2009 Link to this post


    Can you improve either RadGrid or RadColorPicker to have color-editing columns, with html color values (#FFFFFF), to have bidirectionnal databinding please ?


  4. Georgi Tunev
    Georgi Tunev avatar
    7207 posts

    Posted 20 May 2009 Link to this post

    Hi Damien,

    I am afraid I don't see a "color column" implemented in RadGrid in the foreseeable future, as this data type is rather rarely used in grid controls and such a task will have a very low priority in our development team. In addition, this data type does not exist in databases either.

    Using a template column with a RadColorPicker as an edit control is the way to go in this scenario - template columns are by design meant for custom data types, which are presented and edited in a custom way. Here is an example of template column editing:


    For convenience I attached to this thread a small sample that shows how to achieve the desired result. For demo purposes the data is stored in the session.

    All the best,
    Georgi Tunev
    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.
Back to Top