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

[Solved] Custom ControlTemplate per Row

2 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Liam
Top achievements
Rank 1
Liam asked on 04 Aug 2009, 06:40 AM
I have a DataGridView that I want to use for editing records, with just a single attribute\column available for editing.  However, the control that I present to the user for editing will change depending upon other attributes of the underlying record, for example on one row I may have a simple textbox, on another a combobox of available choices, etc.

I have been able to get the different controls displayed by definining ControlTemplates within the UserControl.Resources section as described elsewhere, however I can't then associated the values entered by the user with my underlying record.  For example, when the SelectionChanged event is fired for a combobox, I have no visibility of which record\row the combobox belongs to.  I've tried setting the Tag of the Binding object to be my record, but that crashes saying it can't be modified once it's used.  Because I've replaced the edit control, I no longer get the CellEditEnded event firing so can't pick up events that way....

So in short, what is the solution for having custom ControlTemplates, assigned at runtime, and then re-binding back to the original data source?

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Aug 2009, 05:25 AM
Hi Liam,

Most probably DataContext for the controls in your custom template is still the original data item. Can you check this and let me know about the result?

Kind regards,
Vlad
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
Liam
Top achievements
Rank 1
answered on 05 Aug 2009, 11:20 PM
Hi,

Found an alternative way of setting things up in a different post...rather than setting the Cell's template to reference a user resource, I set the parent column EditorSettings to use the ComboBoxEditorSettings, this way the CellEditEnded is correctly fired and all the binding works without any additional coding.
Tags
GridView
Asked by
Liam
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Liam
Top achievements
Rank 1
Share this question
or