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

Change CellTemplate and CellEditTemplate based on content of another column

3 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ujjwal Lahoti
Top achievements
Rank 1
Ujjwal Lahoti asked on 28 Apr 2010, 05:46 PM
I want to change the CellTemplate and CellEditTemplate of GridViewDataColumn, based on the value of another column.

eg. If Column A has drop down box, with two entries: TextBlock and ComboBox. Based on the selection of column A, I want the column B to have that control.

If you can provide me some sample code that accomplishes this it would be very useful.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 30 Apr 2010, 02:53 PM
Hello Ujjwal Lahoti,

I am attaching you a sample project with the scenario you need. It is implemented with IValueConverter  In the example the third column depends on the property "CountryID" and  it is either ComboBox or TextBlock.
This scenario is applicable for both Silverlight and WPF. You may accomplish the same result with DataTriggers, but it is only for WPF. 

I hope this helps. 

All the best,
Maya
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ramin
Top achievements
Rank 1
answered on 06 Oct 2010, 12:18 AM
Hi Maya,
A very good sample code. I am using only WPF and I just want to change the CellEditTemplate based on the data of the same cell. Can you please show me how I can do this with DataTriggers.
Thanks,
Ramin
0
Maya
Telerik team
answered on 11 Oct 2010, 02:14 PM
Hello Ramin,

In order to offer you a proper solution, I would need a bit more information about your exact requirements. What would be the element inside the CellEditTemplate - TextBox, TextBlock, ComboBox, etc. ? Is it not appropriate for your case to define CellEditTemplate for every specific column ?
 

Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Ujjwal Lahoti
Top achievements
Rank 1
Answers by
Maya
Telerik team
Ramin
Top achievements
Rank 1
Share this question
or