cannot get HEX color value in .cs page:

3 posts, 0 answers
  1. nagarjun
    nagarjun avatar
    21 posts
    Member since:
    Jan 2009

    Posted 09 Mar 2009 Link to this post


        In my project i need to use Color picker in Grid and get this HEX color value which is choosen and save to database for further usage.

        In Grid i have used Template column for color picker as follows:

    <telerik:GridTemplateColumn HeaderText="Color" UniqueName="Color" Visible="false">
    <telerik:RadColorPicker runat="server" ID="RadColorPicker1" OnClientColorChange="HandleColorChange" Preset="Standard" Width="170"/>
    <input type="text" value="" id="HEXColor" />

    When clicked on color on color picker items, the HEX color value is displayed in input type 'HEXColor' as text by using javascript functions as follows:

    function HandleColorChange(sender,eventArgs)

    Here the problem is: because i need to save this HEX value into database i need this HEX value which is displayed in input type text field(id=HEXColor) to be accessed in .cs page.
    Please, let me know how to access this HEX value in .cs page. And its not compulsory that i have to use input type i can also use lable, textbox.

    Nagarjun S.
  2. nagarjun
    nagarjun avatar
    21 posts
    Member since:
    Jan 2009

    Posted 10 Mar 2009 Link to this post


       I have changed the above functionality a little bit and able to get colorPicked value in .cs page.

       The other thing now is .. i have converted the color clicked by user to RGB value say 125,25,100 ans saved it to database. Now i need to any of the thing below.

    1) make the ColorPicker selected color to that color which is previously saved in database(125,25,100) i.e)colorPicker shd be in selected mode to color 125,25,100.

    2)or use template column in grid and display that saved color in database. So that user can see that template and knows which color was previously there.

    Nagarjun S. 
  3. Svetlina Anati
    Svetlina Anati avatar
    2795 posts

    Posted 11 Mar 2009 Link to this post

    Hi nagarjun,

    I assume that you have tried yourself to bind declaratively color pickers in a grid template in the standard manner you declaratively databing controls. The problem in this setup is caused by the fact that only primitive type properties such as string, int, bool are bindable declaratively. Therefore you cannot provide the color through declarative binding.

    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()));   

    Best wishes,

    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