This example demonstrates how to create a column cell template at runtime. Grid cells display the ASPxHyperLink control created in the template.
Declare a custom class that implements the ITemplate interface.
In the class's InstantiateIn method, create controls that make up the template and add them to the control collection of a container passed as this method's parameter. The container type is different for each template type. For a DataItemTemplate object, the container is of the GridViewDataItemTemplateContainer type. Use the container's properties to obtain a row's information. For example, use the KeyValue property to get a row key (container.KeyValue
).
Create an instance of the template class and assign it to the column's DataItemTemplate property.
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- How to: Create Edit Form Templates Dynamically
- How to: Implement a Dynamical DataItem Template for Several Same-type Columns
(you will be redirected to DevExpress.com to submit your response)