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

AutoGeneratingColumn CellTemplateSelector

2 Answers 200 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Guru
Top achievements
Rank 2
Guru asked on 03 Aug 2011, 08:05 PM
I am needing to apply celltemplateselectors at runtime to dynamic grid columns from observablecollection<T>.
Do you have any documentation or examples that show applying celltemplateselectors to grid columns in code behind purely?
I have DataTemplates in a Resource Dictionary and I would like to use the business object value in the cell to decide the datatemplate to select.

Example:
private void grid_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
{
    if (e.Column.UniqueName.Equals("SpecificColumn", StringComparison.CurrentCultureIgnoreCase))
    {
        e.Column.CellTemplateSelector = // ... point to C# class that returns datatemplate from resource dictionary file
    }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 04 Aug 2011, 12:06 PM
Hello Zack,

I have prepared an example project that illustrates how to achieve this. Please, refer to it and let us know whether this solution meets your requirements.

Regards,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Guru
Top achievements
Rank 2
answered on 04 Aug 2011, 05:00 PM
Your project pointed out exactly what I was missing thanks.
Tags
GridView
Asked by
Guru
Top achievements
Rank 2
Answers by
Ivan Ivanov
Telerik team
Guru
Top achievements
Rank 2
Share this question
or