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

Update Data in Grid Edit Form - RadColorPicker

2 Answers 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mSchmidt
Top achievements
Rank 1
mSchmidt asked on 10 Oct 2008, 12:49 PM
Hi

I have a RadColorPicker which is located within the edit FormTemplate of a Grid, the problem however is that i cant bind it directly to the data, so iam trying to update the RadColorPicker with the color when an edit is started.

This is what i tried.
    
        void RadGrid_Ingredient_ItemCommand(object source, GridCommandEventArgs e)  
        {  
            GridEditableItem editedItem = e.Item as GridEditableItem;  
            (editedItem.FindControl("RadColorPicker1"as RadColorPicker).SelectedColor = e.Item.BackColor;  
        } 


Doesnt work.

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 14 Oct 2008, 08:01 AM
Hello mSchmidt,

You can use the ItemDataBound event handler. This may look something like:

.aspx
 <telerik:GridTemplateColumn UniqueName="template1">  
                    <EditItemTemplate> 
                    <telerik:RadColorPicker runat="server" id="Cp1">  
                    </telerik:RadColorPicker> 
                    </EditItemTemplate> 
                    </telerik:GridTemplateColumn> 

.cs
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)  
        {  
            GridEditFormItem editForm = (GridEditFormItem)e.Item;  
            (editForm["template1"].FindControl("Cp1") as RadColorPicker).SelectedColor =System.Drawing.Color.Red;  
        }  
    } 

I hope this suggestion helps.

Greetings,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mSchmidt
Top achievements
Rank 1
answered on 14 Oct 2008, 09:05 PM
Works great !.
Thanks
Tags
Grid
Asked by
mSchmidt
Top achievements
Rank 1
Answers by
Yavor
Telerik team
mSchmidt
Top achievements
Rank 1
Share this question
or