What if we wanted to show two or more data field values in a single GridView column? What if a particular field needs to display some text, a checkbox, and an image, all based upon different data field values? Or what if we wanted to display the data using a Web control other than the CheckBox, Image, HyperLink, or Button? Furthermore, the BoundField limits its display to a single data field. A CheckBoxField can only display a single checkbox, whereas an ImageField can only display a single image. While the CheckBoxField, ImageField, HyperLinkField, and ButtonField field types allow for an alternate view of the data, they still are fairly limited with respect to formatting. Hyperlinks and buttons whose state depends on an underlying data field value can be rendered using the HyperLinkField and ButtonField field types. The CheckBoxField, for example, renders as a checkbox whose checked state depends on the value of a specified data field the ImageField renders an image whose image source is based upon a specified data field. Other field types display the data using alternate HTML elements. The simplest field type is the BoundField, which displays a data value as text. The GridView is composed of a set of fields that indicate what properties from the DataSource are to be included in the rendered output along with how the data will be displayed.
#Grid control devexpress how to#
In this tutorial we'll examine how to use the TemplateField to achieve a greater degree of customization with the GridView control. A template can include a mix of static HTML, Web controls, and databinding syntax. To provide flexibility, the GridView offers the TemplateField, which renders using a template.